code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import numpy as np class A : def __init__( self: Tuple ) -> Any: '''simple docstring''' UpperCAmelCase_ =(0, 0) UpperCAmelCase_ =None UpperCAmelCase_ =0 UpperCAmelCase_ =0...
54
"""simple docstring""" def _lowercase ( __snake_case ,__snake_case ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def _lowercase ( ) -> None: assert or_gate(0 ,0 ) == 0 assert or_gate(0 ,1 ) == 1 assert or...
293
0
'''simple docstring''' def __lowerCAmelCase (SCREAMING_SNAKE_CASE = 10 , SCREAMING_SNAKE_CASE = 1000 , SCREAMING_SNAKE_CASE = True )-> int: """simple docstring""" assert ( isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ...
703
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
531
0
import os def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> List[Any]: _A = len(grid[0] ) _A = len(_snake_case ) _A = 0 _A = 0 _A = 0 # Check vertically, horizontally, diagonally at the same time (only wor...
2
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def ...
251
0
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from...
419
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor...
419
1
'''simple docstring''' from statistics import mean, stdev def __UpperCAmelCase ( _UpperCAmelCase : List[str] , _UpperCAmelCase : Union[str, Any] = 3 ) -> Union[str, Any]: __snake_case = min(__lowercase ) __snake_case = max(__lowercase ) # normaliz...
69
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
23
0
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''snap-research/efficientformer-l1-300''': ( '''https://huggingface.co/snap-research/efficientformer-l1...
703
import unittest import numpy as np def UpperCamelCase( lowercase_ , lowercase_ , lowercase_ , lowercase_ = None , ) -> np.ndarray: '''simple docstring''' snake_case_ = np.shape(lowercase_ ) snake_case_ = np.shape(lowercase_ ) ...
161
0
"""simple docstring""" import sys from collections import defaultdict class snake_case_ : def __init__( self ): a_ : int = [] def snake_case_ ( self , a_ ): return self.node_position[vertex] def snake_case_ ( self , a_ ...
237
"""simple docstring""" SCREAMING_SNAKE_CASE_ = """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""" def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__ ) -> bytes: # Make sure the supplied data is a bytes-like object if not isinstance(SCREAMING_SNAKE_CASE__, ...
237
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSe...
709
'''simple docstring''' import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor __lowercase = logging.get_logger(__name__) class _snake_case ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Union[str...
305
0
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def _UpperCamelCase ( UpperCamelCase__ ): """simple docstring""" for param in module.parameters(): __magic_name__ : Tuple =...
436
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Union[str, Any] = { "micros...
436
1
"""simple docstring""" import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils...
22
"""simple docstring""" import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import...
22
1
'''simple docstring''' import unittest import numpy as np def __UpperCamelCase ( a : np.ndarray , a : np.ndarray , a : np.ndarray , a : np.ndarray | None = None , ) ->np.ndarray: snake_case = np.shape(a ) snake_c...
342
'''simple docstring''' import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": _lowercase = argparse.ArgumentParser() parser.add...
342
1
"""simple docstring""" import numpy as np def lowercase ( __UpperCamelCase ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
718
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVi...
190
0
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def _UpperCAmelCase ( a : str ): if "model" in orig_key: snake_case__ = orig_key.replace("""model.""" , """""" ) if "norm1" in orig_key: snake_case__ ...
654
class _lowerCAmelCase : """simple docstring""" def __init__( self : List[Any] , UpperCamelCase__ : int): '''simple docstring''' snake_case__ = size snake_case__ = [0] * size snake_case__ ...
654
1
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class snake_case ( UpperCAmelCase ): def __init__( self : Optional[Any] , A : str , A : List[st...
118
"""simple docstring""" import os def snake_case (): '''simple docstring''' a : str = os.path.join(os.path.dirname(A_ ) , 'num.txt' ) with open(A_ ) as file_hand: return str(sum(int(A_ ) for line in file_hand ) )[:1_0] if __name__ == "__main__": ...
118
1
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import Bat...
434
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ : Dict ={ 'configuration_perceiver': ['PERCEIVER_PRE...
434
1
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that...
334
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch...
334
1
from datetime import datetime import matplotlib.pyplot as plt import torch def _a ( UpperCamelCase_ : Union[str, Any] ) -> Dict: """simple docstring""" for param in module.parameters(): lowerCAmelCase__ = False def _a ( ) -> Optional[Any]:...
339
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_diffus...
339
1
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin fro...
721
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils ...
464
0
def lowercase__ ( __snake_case : Tuple ): '''simple docstring''' UpperCAmelCase_ : Tuple = 0 UpperCAmelCase_ : List[str] = len(__snake_case ) for i in range(n - 1 ): for j in range(i + 1 , __snake_case ): ...
406
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = R'\n Args:\n input_ids (...
406
1
import argparse import struct import unittest class _UpperCamelCase : def __init__( self :List[str] , lowerCamelCase :bytes ) -> Dict: UpperCAmelCase__ = data # Initialize hash values UpperCAmelCase__ = [ 0x6a09e667, ...
712
import torch from transformers import AutoModel class _UpperCamelCase ( torch.nn.Module ): def __init__( self :str , lowerCamelCase :Tuple="sayef/fsner-bert-base-uncased" ) -> int: super(lowerCamelCase , self ).__init__() UpperCAmelCase__ = ...
364
0
"""simple docstring""" import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCAmelCase ...
58
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : float , __UpperCamelCase : float ): '''simple docstring''' if density <= 0: raise ValueError("""Impossible fluid density""" ) if bulk_modulus <= 0...
58
1
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_ca...
458
def _UpperCAmelCase ( UpperCAmelCase : int = 4_000_000 ): """simple docstring""" __lowerCamelCase : Union[str, Any] = [0, 1] __lowerCamelCase : Dict = 0 while fib[i] <= n: fib.append(fib[i]...
458
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, resc...
90
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__na...
104
0
from timeit import timeit def _A ( _UpperCamelCase ): if number < 0: raise ValueError('''the value of input must not be negative''' ) _UpperCAmelCase : Any = 0 while number: number &= number - 1 result += 1 return result def _A ( _UpperCame...
720
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase__ : Optional[int] = get_tests_dir('fixtures...
416
0
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to...
606
'''simple docstring''' from collections import defaultdict from math import gcd def A_ ( __SCREAMING_SNAKE_CASE : int = 1_50_00_00 ) -> int: __SCREAMING_SNAKE_CASE : defaultdict = defaultdict(__SCREAMING_SNAKE_CASE ) __SCREAMING_SNAKE_CASE : ...
158
0
from __future__ import annotations def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , ): '''simple docstring''' _lowerCAmelCase : List[str] = len(_lowerCamelC...
658
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _snake_case = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {BLEU: a Method for Automatic Evalua...
658
1
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_at...
495
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __UpperCAmelCase ( _lowerCamelCase , unittest...
495
1
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _snake_case : int = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), ...
721
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _snake_case : List[str] = Lock() def A__ ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCa...
524
0
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImage...
560
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __A : '''simple docstring''' def UpperCAmelCase ( self : Any ,_snake_ca...
560
1
def __lowercase ( _A , _A ) -> str: SCREAMING_SNAKE_CASE : int = len(_A ) SCREAMING_SNAKE_CASE : int = len(_A ) SCREAMING_SNAKE_CASE : int = ( first_str_length if first_str_length > second_str_length else sec...
446
def __lowercase ( _A , _A ) -> int: assert x is not None assert y is not None SCREAMING_SNAKE_CASE : int = len(_A ) SCREAMING_SNAKE_CASE : Union[str, Any] = len(_A ) # declaring the array for storing the dp values ...
446
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : Tuple = logging.get_logger(__name__) UpperCamelCase_ : List[Any] = { """facebook/timesformer""": """https://huggingface.co/facebook/timesformer...
331
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuratio...
331
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def _snake_case ( self : List[str] ): '''simple docstring''' ...
707
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Optional[Any] = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if not is_torch_available():...
458
0
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_pro...
12
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCamelCase_ = '''.''' if __name__ == "__main__": UpperCamelCase_ = os.path.join(REPO_PATH, '''utils/documentation_t...
209
0
from timeit import timeit __lowerCAmelCase : Tuple = { "MALAYALAM": True, "String": False, "rotor": True, "level": True, "A": True, "BB": True, "ABC": False, "amanaplanacanalpanama": True, # "a man a plan a canal panama" } # Ensure our test data is valid a...
284
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class __lowerCAmelCase ( lowerCAmelCase_ , unittest.TestCase ...
284
1
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common impor...
88
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case ...
200
0
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...t...
604
import heapq import sys import numpy as np _lowerCAmelCase : str = tuple[int, int] class __snake_case : def __init__( self ): """simple docstring""" lowerCAmelCase__ = [] lowerCAmelCase__ = set() def SCREAMING_SNAKE_CASE_ ( ...
604
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __A = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try: if not...
59
'''simple docstring''' from math import sqrt def A ( UpperCamelCase_ : int ) -> int: '''simple docstring''' lowerCAmelCase__ = 0 for i in range(1 , int(sqrt(UpperCamelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCamelCase_ ): ...
48
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(lowerCamelCase_)) def SCREAMING_SNAKE_CASE (...
715
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging __a : List[Any] = logging.get_logger(__name__) __a : Tuple = { '...
200
0
from __future__ import annotations def a_ ( _A ) -> int: """simple docstring""" snake_case__ = len(_A ) // 2 # choose the middle 3 elements snake_case__ = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[0] and ...
328
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
328
1
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available()...
718
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger UpperCAmelCase_ : int = get_logger(__name__) class lowercase__ ( enum.Enum ): __UpperCamelCase = """all_checks""" __UpperCamelCase ...
440
0
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : Dict[str, torch.Tensor] ): '''simple docstring''' UpperCAmelCase_...
603
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _a : Tuple = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """w...
145
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _UpperCAmelCase = { 'configuration_layoutlmv3': [ 'LAYOUTLMV3_PRETRAINED_CO...
240
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetY...
240
1
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavLM impo...
271
def lowerCamelCase_ ( UpperCAmelCase_ : int = 10**12 ): lowercase : List[str] = 1 lowercase : Optional[Any] = 0 lowercase : Tuple = 1 lowercase : Optional[int] = 1 while numerator ...
583
0
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class UpperCamelCase__ : """simple docstring""" def __init__( self ): '''simple docstring''' _lowerCAmelCase : ...
630
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins lowerCAmelCase : List[str] = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def lowercase (_A , _A ): ...
630
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_ch...
48
from typing import Union import fire import torch from tqdm import tqdm def SCREAMING_SNAKE_CASE ( snake_case__ , snake_case__ = "cpu" , snake_case__ = None ) -> None: __UpperCAmelCase =torch.load(snake_case__ , map_location=snake_case__ ) for k, v in tqdm(state_...
132
0
__lowerCamelCase : str = [ 9_99, 8_00, 7_99, 6_00, 5_99, 5_00, 4_00, 3_99, 3_77, 3_55, 3_33, 3_11, 2_88, 2_66, 2_44, 2_22, 2_00, 1_99, 1_77, 1_55, 1_33, 1_11, 88, 66, 44, 22, 0, ] __lowerCamelCa...
501
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) de...
501
1
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
60
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeli...
121
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor _lowercase : List[str] =logging.get_logger(__name__) class lowerCAmelCase_ ( A_ ): '''simple docstring''' def __init__( self , *lowerCamelCase , ...
412
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
412
1
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class SCREAMING_SNAKE_CASE ( yaml.SafeLoader ): """simple docstring""" def __A ( self: Dict , __A: Any ) -> int: _A = [self.const...
484
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __A = logging.get_logger(__name__) __A = {...
484
1
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPa...
702
'''simple docstring''' def A__ ( A_ ) -> int: assert ( isinstance(A_ , A_ ) and number_of_steps > 0 ), F"""number_of_steps needs to be positive integer, your input {number_of_steps}""" if number_of_steps == 1: return 1 _lowercase , _lowercase = ...
602
0
"""simple docstring""" import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def a__ ( lowe...
82
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from ...
143
0
"""simple docstring""" import requests from bsa import BeautifulSoup def __UpperCAmelCase ( lowercase = "AAPL" ): """simple docstring""" _UpperCAmelCase = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' _UpperCAmelCase = BeautifulSoup(requests.get(lowe...
275
"""simple docstring""" import unittest from knapsack import knapsack as k class a ( unittest.TestCase ): def lowerCAmelCase_ ( self : List[Any] ): _UpperCAmelCase = 0 _UpperCAmelCase = [0] _UpperCAmelCase = [0] _UpperCAmelCa...
275
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def _A ( _lowercase ) -> Tuple: """simple docstring""" monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set() ) @pytest....
1
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionM...
51
0
"""simple docstring""" class lowerCamelCase__ : """simple docstring""" def __init__( self : Optional[int] ): '''simple docstring''' __UpperCAmelCase : Optional[int] = """""" __UpperCAmelCase : Any = ...
299
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Imag...
299
1
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_re...
20
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConf...
494
0
from __future__ import annotations def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" if len(lowerCamelCase__ ) < k or k < 0: raise ValueError("Invalid Input" ) lowercase__ : Dict = sum(array[:k] ) for i in range(len...
81
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
81
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def lowerCamelCase__ (): _SCREAMING_SNAKE_CASE : List[Any] = ArgumentParser( description=( "...
249
"""simple docstring""" import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowerCAmelCase__ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( lowercase ): """simple docstring""" def __init_...
645
0
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): ...
720
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_fu...
317
0
from numpy import exp, pi, sqrt def A ( snake_case__ : List[str] , snake_case__ : float = 0.0 , snake_case__ : float = 1.0 ) -> Optional[Any]: '''simple docstring''' return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) ...
313
from __future__ import annotations def A(__a: list[int] , __a: list[int] , __a: int ): lowerCAmelCase_ = list(range(len(__a ) ) ) lowerCAmelCase_ = [v / w for v, w in zip(__a , __a )] index.sort(key=lambda __a : ratio[i] , ...
122
0
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data ...
368
'''simple docstring''' import cva import numpy as np class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self , lowerCamelCase , lowerCamelCase ): if k in (0.04, 0.06): _snake_case = k _snake_case = window_...
368
1
from __future__ import annotations import collections import pprint from pathlib import Path def snake_case__ ( SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' return "".join(sorted(SCREAMING_SNAKE_CASE_ ) ) def snake_case__ ( SCREAMING...
164
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder snake_case_ = datasets.utils.logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ (folder_based_builder.FolderBasedBuilderConfig ): __lowerCamelC...
164
1
"""simple docstring""" import os a :List[str] = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000} def _lowercase ( __lowerCAmelCase ) -> int: SCREAMING_SNAKE_CASE__ : Any = 0 SCREAMING_SNAKE_CASE__ : Dict = 0 while in...
12
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequence...
12
1
'''simple docstring''' from math import pi def __lowercase (_lowercase, _lowercase ) -> float: """simple docstring""" return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
150
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def __lowercase (_lowercase, _lowercase, _lowercase, _lowercase, _lowercase = None, _lowercase = None, _lowercase...
150
1
from functools import lru_cache def lowercase ( a ): '''simple docstring''' SCREAMING_SNAKE_CASE_ :List[str] = 2 SCREAMING_SNAKE_CASE_ :Dict = set() while i * i <= n: if n % i: i += 1 else: n //= i factors.add(a ) if n > 1: ...
140
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_...
140
1
from __future__ import annotations import math from collections.abc import Callable def lowercase__ ( A_: Callable[[int | float], int | float] , A_: int | float , A_: int | float , A_: int = 100 , ) -> float: """simple docstring""" ...
68
'''simple docstring''' import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMR...
372
0
import math from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Any = logging.get_logger(__name__) __lowerCAmelCase : Dict = { "facebook/data2vec-base-960h": "https://huggingface.co/facebook/data2vec-audio-base-960h/resolve...
284
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowerCAmelCase ( datasets.BuilderConfig ): """simple docstring""" ...
284
1
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokenizers __...
629
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) class A__ ( __snake_case ): def __init__( self , *A_ , **A_ ): '''simple docstring''' ...
629
1
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" if not isinstance(UpperCAmelCase , UpperCAmelCase ): a_ = F'''Input value of [number={number}] must be an integer''' raise TypeError(UpperCAmelCase ) if numbe...
714
"""simple docstring""" import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
210
0
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def _snake_case ( A ) -> Dict[str, torch.Tensor]: lowerCAmelCase__ = [] lowerCAme...
90
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import torch from ....
298
0
'''simple docstring''' def lowerCAmelCase( a__ : Tuple=2_8123 ): '''simple docstring''' lowerCamelCase__ = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i +...
426
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if...
426
1
"""simple docstring""" import os import re import shutil import sys import tempfile import unittest import black __A = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_copies # noqa: E402 ...
93
'''simple docstring''' import heapq import sys import numpy as np UpperCAmelCase__ :Optional[Any] = tuple[int, int] class SCREAMING_SNAKE_CASE : def __init__( self : int ): """simple docstring""" __lowerCamelCase :...
150
0
'''simple docstring''' lowercase_ = [ '''DownloadConfig''', '''DownloadManager''', '''DownloadMode''', '''StreamingDownloadManager''', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownlo...
58
'''simple docstring''' import unittest from knapsack import knapsack as k class SCREAMING_SNAKE_CASE ( unittest.TestCase): """simple docstring""" def UpperCamelCase__ ( self ) -> Optional[Any]: _lowerCAmelCase =0 _lowerCAmelCase =[0] ...
58
1
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils imp...
657
"""simple docstring""" def __A ( a_ : int = 10 , a_ : int = 10_00 , a_ : bool = True )-> int: '''simple docstring''' assert ( isinstance(a_ , a_ ) and isinstance(a_ , a_ ) and isinstance(a_ , a_ ) ), "Invalid type of value(s) specified to funct...
698
0
import copy import re class snake_case__ : __A = '''hp''' __A = {} __A = None @classmethod def UpperCamelCase ( cls : Union[str, Any] , lowerCAmelCase_ : List[str] , lowerCAm...
712
from __future__ import annotations import math def _lowerCAmelCase ( __magic_name__ :int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all m...
407
0
import random def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase ) -> tuple: """simple docstring""" snake_case_ , snake_case_ , snake_case_ : Optional[Any] = [], [], [] for element in data: if element < pivot: ...
60
"""simple docstring""" import argparse import os import re lowerCamelCase_ = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowerCamelCase_ = re.compile(r...
498
0
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase ( __lowerCamelCase ): def __UpperCAmelCase ( self : Optional[Any]) -> Optional[int]: return [ {"col_...
461
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy a...
461
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available snake_case__ : Tuple = { """configuration_longt5""": ["""LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LongT5Config""", """LongT5OnnxConfig"""], } try: if not ...
402
from math import sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number are in format o...
402
1
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import...
32
def UpperCAmelCase__ ( UpperCAmelCase__ :Any ): '''simple docstring''' if not head: return True # split the list to two parts a , a = head.next, head while fast and fast.next: a = fast.next.next a = slow.next a = slow.next a = N...
32
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils impo...
159
from ..utils import DummyObject, requires_backends class __lowercase ( metaclass=_SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCAmelCase_ : Optional[Any] = ['''speech'''] def __init__( self , *__UpperCAmelCase ...
542
0
from ....configuration_utils import PretrainedConfig from ....utils import logging __a : Dict = logging.get_logger(__name__) __a : List[Any] = { '''speechbrain/m-ctc-t-large''': '''https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json''', # See al...
298
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr...
298
1
"""simple docstring""" import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling...
224
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ )-> int: """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: UpperCamelCase_ = _modexpt(SCREAMING_SNAKE_CASE_ , ...
628
0
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a__ = TypeVar("""KEY""") a__ = TypeVar("""VAL""") @dataclass(frozen=SCREAMING_SNAKE_CASE_ ,slots=SCREAMING_SNAKE_CASE_ ) class snake_case ( Generic[K...
198
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor...
198
1
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowercase__ = input("""Enter image url: """).strip() print(F"Downloading image from {url} ...") lowercase__ = BeautifulSoup(requests.get(url).cont...
630
"""simple docstring""" import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class lowerCAmelCase__ ( tf.keras.l...
630
1
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def A ( _lowercase ): return x + 2 class lowercase__ ( unittest.TestCase): def __A ( self : Tuple ): '''...
703
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class lowercase__ ( UpperCamelCase_): def __init__( self : str , UpperCamelCase__ : Optional[int] , UpperCamelCase__ : Optio...
34
0
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common impo...
15
import numpy # List of input, output pairs A_ : Any = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) A_ : List[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) A_ : ...
57
0
def lowerCamelCase__ ( snake_case_ : str ) -> int: assert column_title.isupper() __snake_case = 0 __snake_case = len(snake_case_ ) - 1 __snake_case = 0 while index >= 0: __snake_case = (ord(column_title[index] ...
388
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
388
1
'''simple docstring''' from __future__ import annotations def lowerCamelCase (_SCREAMING_SNAKE_CASE : list[float] ): __a : List[str] = 0.0_0 __a : int = 0 for resistor in resistors: if resistor <= 0: __a : Dict ...
476
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common im...
146
0
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever lowerCamelCase : str = logging.getLogger(__name__) class __lowercase (UpperCAmelCase__ ): """simple docstrin...
710
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : Dict = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolv...
684
0
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _a ( UpperCamelCase__ ): def lowerCamelCase_ ( self: List[Any] , UpperCamelCase_: float ) -> float: ...
43
'''simple docstring''' from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class lowerCAmelCase_ ( lowerCamelCase_ ): '''simple docstring''' def __lt__( self : List[Any] , _Upper...
603
0
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_...
711
'''simple docstring''' import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging UpperCamelCase__ : Optional[Any] = logging.get_logger(__name__) UpperCamelC...
385
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_camembert import ...
192
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase: Optional[Any] = { '''configuration_rag''': ['''RagConfig'''], '''retrieval_rag''': ['''RagRetriever'''], '''tokenization_rag''': ['''RagTokenizer'''...
192
1
'''simple docstring''' import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, ...
711
'''simple docstring''' def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : List[str] , SCREAMING_SNAKE_CASE_ : Tuple ) -> Optional[int]: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = [1] for i in range(2 , SCREAMING...
68
0
'''simple docstring''' from math import sqrt def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(SCREAMING_SNAKE_CASE_ ) + 1 ) ): if n % i == 0 and i != sqrt(SCREAMING_SNAKE_CASE_ ...
591
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTes...
591
1
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Co...
704
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATIO...
239
0
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import Se...
39
import os import jsonlines import numpy as np from tqdm import tqdm _UpperCamelCase = 2048 _UpperCamelCase = 4096 _UpperCamelCase = 42 _UpperCamelCase = os.environ.pop('''PROCESS_TRAIN''', '''false''') _UpperCamelCase = {'''null''': 0, '''short'''...
146
0
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _snake_case( ) -> List[str]...
586
def _snake_case( SCREAMING_SNAKE_CASE__ : int = 10 , SCREAMING_SNAKE_CASE__ : int = 22 ) -> int: '''simple docstring''' A__ = range(1 , SCREAMING_SNAKE_CASE__ ) A__ = range(1 , SCREAMING_SNAKE_CASE__ ) ...
586
1
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE=() , SCREAMING_SNAKE_CASE=None , SCREAMING_SNAKE_CA...
167
import requests __lowercase = '''''' # <-- Put your OpenWeatherMap appid here! __lowercase = '''https://api.openweathermap.org/data/2.5/''' def lowerCamelCase ( SCREAMING_SNAKE_CASE = "Chicago" , SCREAMING_SNAKE_CASE = APPID ): '''simple docstring''' return reques...
167
1
def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = 0 __lowerCAmelCase = len(snake_case_ ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_co...
719
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging A : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name class _UpperCame...
282
0
"""simple docstring""" from collections import defaultdict from math import gcd def lowercase ( UpperCamelCase : int = 1500000 ): """simple docstring""" A__ : defaultdict =defaultdict(UpperCamelCase ) A__ : Any =2 while 2 * euclid_m * (euclid_m + ...
656
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __lowerCAmelCase ( unittest.TestCase): '''simple docstring''' def ...
656
1
def __snake_case ( UpperCamelCase , UpperCamelCase ) -> float: """simple docstring""" if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 ...
713
"""simple docstring""" import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_fl...
158
0