code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str ) -> List[Any]: assert x is not None assert y is not None __lowercase = len(SCREAMING_SNAKE_CASE ) __lowercase = len(SCREAMING_SNAKE_CASE )...
325
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger SCREAMING_SNAKE_CASE__ = get_logger(__name__) class A__ ( enum.Enum ): lowerCAmelCase__ : Dict = "all_checks" lowerCAmelCase__ : ...
325
1
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTeste...
261
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _A = { '''configuration_encodec''': [ '''ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''EncodecConfig''', ], '''feature_extraction_encodec''': ['''...
261
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer _a : List[Any] = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'token...
44
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast _a : Dict = datasets.utils.logging.get_logger(__name__) @dataclass class __A...
44
1
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableUnCLI...
63
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _UpperCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
63
1
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set...
144
"""simple docstring""" A__ : Optional[int] = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', ...
144
1
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelC...
366
import re def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if len(re.findall("[ATCG]" , a__ ) ) != len(a__ ): raise ValueError("Invalid Strand" ) return dna.translate(dna.maketrans("ATCG" , "TAGC" ) ) if __name__ == "__main__": import doctes...
63
0
"""simple docstring""" def __lowercase ( snake_case_ : dict ) ->set: '''simple docstring''' __A : List[str] = set() # edges = list of graph's edges __A : Optional[int] = get_edges(snake_case_ ) # While there are still elem...
179
"""simple docstring""" import unittest import numpy as np import requests 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_inpu...
179
1
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Con...
369
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _lowercase ( UpperCamelCase_ ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE__ = int(number**0.5 ) return number == sq * sq def _lowercase ...
169
0
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _A ( SCREAMING_SNAKE_CASE : dict ): ...
95
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnaly...
269
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( __A ): '''simple docstring''' lowerCamelCase_ = (EulerDiscreteScheduler,) lowerCamelCase_ ...
192
from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=__A ): '''simple docstring''' lowerCamelCase_ = ['''onnx'''] def __init__( self , *lowercase , **lowercase ): """simple docstring""" require...
192
1
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowerCAmelCase_ ( _lowercase ): '''simple docstring''' _lowerCamelCase: Union[str, Any] = (IPNDMScheduler,) _lowerCamelCase: ...
74
from __future__ import annotations class A : def __init__(self : Union[str, Any] , __UpperCAmelCase : list[list[int]] ) -> List[str]: """simple docstring""" UpperCAmelCase__ = TypeError( "Matrices must be for...
65
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _UpperCAmelCase : List[Any] = False class __lowerCAmelCase ( unittest.TestCase): de...
158
from typing import TYPE_CHECKING from ...utils import _LazyModule _UpperCAmelCase : Optional[int] = {"processing_wav2vec2_with_lm": ["Wav2Vec2ProcessorWithLM"]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys _UpperCAmelCase : i...
158
1
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCamel...
181
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ = { '''configuration_distilbert'...
181
1
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __Upp...
74
"""simple docstring""" # 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]' whe...
74
1
"""simple docstring""" def lowerCAmelCase__ ( _UpperCamelCase : int ) -> bool: """simple docstring""" if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": impor...
150
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Any class lowerCAmelCase_ : """simple docstring""" def __init__( self , lowerCAmelCase ): """simple docstring""" snake_case ...
150
1
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCamelCase__ =logging.get_logger(__name__) class lowerCAmelCase__( __lowercase ): '''simple docstring''' def __init__( self , *__lowerCamelCase ...
325
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 logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ...
325
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def UpperCamelCase( __UpperCamelCase : Union[str, Any] ): lowerC...
103
'''simple docstring''' def _UpperCamelCase ( __A ) -> int: '''simple docstring''' UpperCamelCase__ = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def _UpperCamelCase ( __A = 100 ) ...
80
0
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_availab...
353
"""simple docstring""" import warnings from functools import wraps from typing import Callable def __lowerCAmelCase (_UpperCamelCase ): @wraps(_UpperCamelCase ) def _inner_fn(*_UpperCamelCase , **_UpperCamelCase ): warnings.warn( (F"'{fn.__name__}' is experimental and might be subject to br...
182
0
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( A__): _lowerCAmelCase : Dict = (UnCLIPScheduler,) def _snake_case ( self : Optional[int] , **lowercase_ : ...
264
from __future__ import annotations __a = [] def __lowercase ( _UpperCamelCase, _UpperCamelCase, _UpperCamelCase ) ->bool: """simple docstring""" for i in range(len(_UpperCamelCase ) ): if board[row][i] == 1: return False for i in r...
337
0
'''simple docstring''' # Function to print upper half of diamond (pyramid) def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> Tuple: for i in range(0 , UpperCamelCase ): for _ in range(0 , n - i - 1 ): # printing spaces ...
129
'''simple docstring''' from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_uti...
129
1
'''simple docstring''' import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attenti...
47
'''simple docstring''' import copy import re class A__ : A__ = 'hp' A__ = {} A__ = None @classmethod def A ( cls : Optional[Any] , _a : Optional[Any] , _a : Any ) -> Union[str, Any]: '''simple docstring''' ...
47
1
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : List[Any] ): __UpperCamelCase =0 __UpperCamelCase =len(lowercase__ ) for i in range(n - 1 ): for j in range(i + 1 , lowercase__ ): if arr[i] > arr[j]: ...
351
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging loggi...
117
0
from __future__ import annotations import collections import pprint from pathlib import Path def UpperCamelCase_( lowerCamelCase_ ) -> str: return "".join(sorted(lowerCamelCase_ ) ) def UpperCamelCase_( lowerCamelCase_ ) -> list[str]: return word_by_signature[signatur...
21
"""simple docstring""" import math import random from typing import Any from .hill_climbing import SearchProblem def lowercase ( a__ : str , a__ : bool = True , a__ : float = math.inf , a__ : float = -math.inf , a__ : float = math.inf , a__ : float = -math.inf , a__ : bool = False , a__...
256
0
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipel...
150
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py a : Any = """src/diffusers""" # Matches is_xxx_available() a : Opt...
150
1
from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=lowerCamelCase__): '''simple docstring''' snake_case_ =["""torch"""] def __init__(self ,*__lowerCamelCase ,**__lowerCamelCase ) -> List[Any]: """simple docstring""" requ...
129
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCamelCase__ ( lowerCamelCase__): '''simp...
129
1
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, ...
364
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class SCREAMING_SNAKE_CASE__ ( unittest.TestC...
120
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import ...
277
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( FlaxFo...
13
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @requi...
356
"""simple docstring""" import functools def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> int: # Validation if not isinstance(UpperCAmelCase , UpperCAmelCase ) or not all(isinstance(UpperCAmelCase , UpperCAmelCase ) for day in days ): raise ValueError('The ...
312
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class A : def __init__( self , SCREAMING_SNAKE_CASE ) -> None: """simple docstring""" A : Optional[Any] = ...
3
import random def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> tuple: '''simple docstring''' SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = [], [], [] for element in data: if element < pivot: le...
176
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extrac...
338
'''simple docstring''' import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampl...
338
1
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) _...
93
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE...
93
1
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ) -> List[str]: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) _a : Any = str(bin(A__ ) )[2:] # remove the leading "0b" _a : str...
357
'''simple docstring''' import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
107
0
def UpperCAmelCase_( a__ ): """simple docstring""" if upper_limit < 0: raise ValueError('''Limit for the Catalan sequence must be ≥ 0''' ) SCREAMING_SNAKE_CASE : Optional[int] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SN...
313
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('''ignore''', category=UserWarning, module='''torch.optim.lr_scheduler''') class a_ : """simple d...
313
1
'''simple docstring''' import requests def a__ ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : str ) -> Optional[Any]: """simple docstring""" UpperCAmelCase_ : Any = {"""Content-Type""": """application/json"""} UpperCAmelCase_...
359
'''simple docstring''' import os from pathlib import Path def a__ ( ) -> Union[str, Any]: """simple docstring""" from torch.utils.cpp_extension import load UpperCAmelCase_ : Union[str, Any] = Path(_SCREAMING_SNAKE_CASE ).resolve().parent.parent....
67
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFM...
84
from math import factorial UpperCAmelCase__ = {str(digit): factorial(digit) for digit in range(10)} def _a ( a :int ) -> int: if not isinstance(a , a ): raise TypeError('''Parameter number must be int''' ) if number < 0: raise ValueError('''Parameter numb...
0
0
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, load...
165
def lowercase( UpperCamelCase_ ) -> list[list]: '''simple docstring''' UpperCamelCase = current_set.copy() for row_index, row in enumerate(UpperCamelCase_ ): UpperCamelCase = row[0] for column_index, column in enumerate(UpperCamelCase_ ): if magnitude == 0: ...
165
1
'''simple docstring''' from itertools import product def UpperCAmelCase_ ( __lowercase : int , __lowercase : int ) -> list[int]: '''simple docstring''' _UpperCAmelCase = sides_number _UpperCAmelCase = max_face_nu...
22
import unittest from knapsack import knapsack as k class __a ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self ) -> Tuple: '''simple docstring''' lowercase__: List[Any] = 0 lowercase__: List[Any] = [0] lowe...
196
0
'''simple docstring''' from __future__ import annotations import math def _A ( A__ ): """simple docstring""" 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 ...
52
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''studio-ousia/luke-base''': '''https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json''', ...
52
1
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, load_i...
201
'''simple docstring''' UpperCAmelCase = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' UpperCAmelCas...
141
0
"""simple docstring""" import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __lowercase = HUGGINGFACE_HUB_CACHE __lowercase = """config.json""" __lowercase = """diffusion_pytorch_model.bin""" __lowercase = """diffusion_flax_mode...
360
"""simple docstring""" from __future__ import annotations import queue class _A : """simple docstring""" def __init__( self : List[str] , __UpperCAmelCase : Union[str, Any]): a : Optional[Any] = data ...
226
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDepende...
97
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Acc...
106
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor ...
190
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() excep...
190
1
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline __lowercase = logging.get_logger(__name__) class a...
272
'''simple docstring''' from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
272
1
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import wr...
366
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __UpperCAmelCase (_UpperCAmelCase ,unittest.TestCase ): __snake_case : int ...
125
0
'''simple docstring''' import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessi...
1
'''simple docstring''' import math def lowerCAmelCase_ ( ) -> None: '''simple docstring''' UpperCAmelCase_ = input("Enter message: " ) UpperCAmelCase_ = int(input(f"""Enter key [2-{len(snake_case_ ) - 1}]: """ ) ) UpperCAmelCase_ ...
1
1
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowerCAmelCase : Dict = 2_00 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
363
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTra...
251
0
'''simple docstring''' def UpperCamelCase_ ( A__ : Union[str, Any] ): '''simple docstring''' lowerCAmelCase_ : str = 0 for ch in input_str: lowerCAmelCase_ : Dict = ord(_UpperCamelCase ) lowerCAmelCase_ : str = pow(2...
120
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_utils...
337
0
'''simple docstring''' def UpperCAmelCase ( lowerCamelCase_ :int , lowerCamelCase_ :int ): '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def UpperCAmelCase ( ): '''simple docstring''' assert and_gate(0 , 0 ) == 0 assert an...
8
'''simple docstring''' import collections import os import re from pathlib import Path __A : Dict = 'src/transformers' # Matches is_xxx_available() __A : Dict = re.compile(r'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} __A : Any = re.comp...
8
1
from timeit import timeit def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Optional[int]: '''simple docstring''' if number < 0: raise ValueError('the value of input must not be negative' ) lowerCAmelCase : Any = 0 while number: number &= number - 1...
138
"""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 Image ...
77
0
"""simple docstring""" import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from .....
367
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging ...
85
0
"""simple docstring""" from math import sqrt def _snake_case ( lowercase__ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Ne...
84
"""simple docstring""" import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() d...
84
1
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 ...
109
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] , __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : int ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction =...
109
1
"""simple docstring""" import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowerCamelCase ( __UpperCamelCase , __UpperCamelCase...
241
import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.models.ber...
71
0
'''simple docstring''' import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase = get_tests_dir('fixtures/test_...
187
'''simple docstring''' import numpy class __snake_case: '''simple docstring''' def __init__( self , A_ , A_ ) -> None: lowerCAmelCase = input_array # Random initial weights are assigned where first argument is the # number of nodes...
187
1
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> Any: __lowerCamelCase : Optional[Any] = AutoConfig.from_pretraine...
73
from __future__ import annotations from scipy.special import comb # type: ignore class A_ : def __init__( self : List[str] ,SCREAMING_SNAKE_CASE__ : list[tuple[float, float]]): __lowerCamelCase : Union[str, Any] = list_of_points # Degree d...
73
1
import torch from ..models.auto import AutoModelForSequenceClassification, AutoTokenizer from .base import PipelineTool class UpperCAmelCase ( __a ): '''simple docstring''' lowerCamelCase_ = '''facebook/bart-large-mnli''' lowerCamelCase_ = ( '''This is ...
369
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(__name__) _UpperCAmelCase = {"...
192
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : List[str] ...
14
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers fr...
260
0
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modeli...
353
from random import randint from tempfile import TemporaryFile import numpy as np def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): _A : Tuple = 0 if start < end: _A : Tuple = randint(snake_case_,snake_case_ ) ...
343
0
"""simple docstring""" from math import factorial, pi def snake_case_ ( A_ : Union[str, Any], A_ : Tuple = 30 ): '''simple docstring''' if not isinstance(A__, (int, float) ): raise ValueError('''maclaurin_sin() requires either an ...
72
'''simple docstring''' from PIL import Image def __lowerCamelCase ( A__ , A__ ) -> Image: """simple docstring""" def brightness(A__ ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueEr...
28
0
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttenti...
370
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable a_ = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXConfig"""]} try:...
291
0
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...util...
290
"""simple docstring""" from math import pi, sqrt, tan def __a ( _SCREAMING_SNAKE_CASE ) ->float: if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
290
1
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 lowerCamelCase_ : str = { # 1536-bit 5: { """prime""": int( """F...
223
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _UpperCamelCase ( _A , unittest.TestCase ): '''simple docstring''' __UpperCamelCase : Tu...
223
1
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> List[str]: __lowerCamelCase : List[Any] = len(lowerCamelCase__ ) while cur > 1: # Find the maximum number in arr __lowerCamelCase : List[Any] = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi...
73
'''simple docstring''' import re def __magic_name__ ( __UpperCAmelCase ) -> bool: '''simple docstring''' snake_case_ = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(__UpperCAmelCase, __U...
56
0
'''simple docstring''' from __future__ import annotations import queue class lowerCAmelCase__ : def __init__( self : List[str] , lowerCamelCase__ : Optional[int] ) ->List[str]: '''simple docstring''' _UpperCAme...
322
'''simple docstring''' from __future__ import annotations from collections.abc import Callable lowerCamelCase__ = list[list[float | int]] def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : int = len(__lowerCAmelCase ) _Up...
322
1
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig lowerCAmelCase__ = logging.getLogger(__name__) class SCREAMING_SNAKE_CASE__ ( lowerCamelCase_ ): """simple docstring""" a : List[str] ="masked_bert" de...
108
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_...
219
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class a ( Upper...
363
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils impo...
189
0
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _A : @property def UpperCAmelCase ( self ): """simple do...
253
from jiwer import compute_measures import datasets lowerCAmelCase : Tuple = '\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evaluation...
253
1
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig A_ : Any =logging.getLogger(__name__) class __a ( lowerCAmelCase__ ): SCREAMING_SNAKE_CASE__ : List[Any] = "masked_bert" def __init__( self , ...
80
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> list[int]: if num <= 0: raise ValueError('Input must be a positive integer' ) _lowerCamelCase = [True] * (num + 1) _lowerCamelCase = 2 while p * p <= num: ...
80
1
'''simple docstring''' # Copyright 2021 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/...
349
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex a__ : Optional[Any] = logging.getLogger(__name__) class UpperCAmelCase__ : de...
349
1
'''simple docstring''' from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __magic_name__ ( ) -> Dict: '''simple docstring''' snake_case_ = 9, 14 # noqa: F841 snake_case_ = [ [0, 1, 4], ...
364
'''simple docstring''' import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.model...
72
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils ...
210
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 ...
210
1
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins _SCREAMING_SNAKE_CASE : Optional[int] = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def _lowerCAmelCase ( UpperCAmelCase : Optional[int] , Upper...
157
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort _SCREAMING_SNAKE_CASE : List[Any] = """1""" _SCREAMING_SNAKE_CASE : Union[str, Any] = """0""" _SCREAMING_SNAKE_CASE : List[str] = """1""" _SCREAMING_SNAKE_CASE : Optional[int] ...
157
1
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = prime_factors(_UpperCamelCase ) if is_square_free(_UpperCamelCase ): ...
57
"""simple docstring""" import argparse import os import re import packaging.version A : Any = "examples/" A : Optional[Any] = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__versio...
57
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization_mvp': ['MvpT...
199
'''simple docstring''' from timeit import timeit def _A ( snake_case ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) _lowercase : Union[str, Any] = 0 while number: number &= number - 1 result += 1 ...
199
1
from __future__ import annotations from math import ceil, floor, sqrt def lowerCamelCase_ ( UpperCamelCase__ : int = 200_0000 ) -> int: """simple docstring""" __lowerCamelCase = [0] __lowerCamelCase = 42 ...
90
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Optiona...
176
0
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 __a = logging.get_logger(__name__) __a = {'vocab_file': 'vocab.json', 'merges_...
356
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDetection fr...
235
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer UpperCamelCase = loggi...
319
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTe...
319
1
"""simple docstring""" import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import ...
112
"""simple docstring""" import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __lowerCAmelCase ...
112
1
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 A_ (datasets.BuilderConfig ): UpperCAmelCase__ = None class A_ (datasets.ArrowBasedBuilder ): ...
273
from datetime import datetime import requests def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ ) -> bytes: '''simple docstring''' UpperCAmelCase = '''https://downloadgram.net/wp-json/wppress/video-downloader/video?url=''' UpperCAmelCase = requests.get(base_url + url...
273
1
"""simple docstring""" import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokeniz...
188
"""simple docstring""" # 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.apach...
188
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class A__ ( metaclass=_lowerCamelCase): A_ : Tuple = ['transformers', 'torch', 'note_seq'] def __init__( self , *_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CASE ): requires_backends(s...
86
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''', '''uclanlp/visualbert-vqa-pre'''...
244
0
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def UpperCAmelCase_ ( __UpperCAmelCase : Optional[int] ) -> Tuple: return 1 / (1 + np.exp(-z ...
210
import argparse import os import re lowerCamelCase__ : str = 'src/transformers' # Pattern that looks at the indentation in a line. lowerCamelCase__ : Tuple = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. lowerCamelCase__ : ...
210
1
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeli...
215
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( _lowerCamelCase ): """simple docstring""" UpperCAmelCase = (IPNDMScheduler,) UpperCAmelCase = (("""num_inferen...
215
1
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, Aut...
359
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[int] = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: ...
127
0
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def a_ ( lowerCAmelCase_ : int = 8 ): __lowerCAmelCase = ascii_letters + digits + punctuation return "".join(secrets.choice(lowerCAmelCase_ ) for _ in range(l...
284
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case : List[Any] = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['BioGptToken...
284
1
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common im...
364
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _...
89
0
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCAmelCase (...
17
"""simple docstring""" from __future__ import annotations from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self : Any, UpperCAmelCase__ : int ): __lowercase = num_of_nodes __lowercase = [] __lo...
17
1
import unittest from transformers import 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 ModelTesterMixin, ids_tensor from ...
127
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[int] = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: ...
127
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _A : str =logging.get_logger(__name__) _A : List[str] ={ ...
41
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome...
41
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( _lowerCAmelCase ): @staticmethod @abstractmethod def a ( _lowercase : ArgumentParser ): raise NotImplementedError() @abst...
366
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase : Tuple ...
86
0
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if ver...
29
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Acceler...
29
1
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ) -> Any: snake_case : ...
176
def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def SCREAMING_SNAKE_CASE__ ( ) -> None: assert or_gate(0 ,0 ) == 0 assert or_gate(0 ,1 ) == 1 assert or_gate(1 ,0 ) ==...
176
1
from math import factorial _lowerCamelCase : dict[str, int] = {str(digit): factorial(digit) for digit in range(10)} def SCREAMING_SNAKE_CASE ( lowercase_ ) -> int: """simple docstring""" if not isinstance(lowercase_ , lowercase_ ): ...
14
"""simple docstring""" import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_...
263
0
"""simple docstring""" class __A : '''simple docstring''' def __init__( self : List[Any] ,_snake_case : Tuple ) -> Any: """simple docstring""" lowercase__ : Dict = arr.split(''',''' ) ...
362
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_...
302
0
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import ...
143
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _A = logging.get_logger(__name__) _A = { """SenseTime/deformable-detr""": """https://huggingface.co/sensetime/deformable-detr/r...
242
0
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transf...
150
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Union[str, Any] = Fals...
150
1
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase : Any = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", # Se...
252
import re import string import numpy as np import datasets UpperCAmelCase : List[str] = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" UpperCAmelCase : str = "\nArgs:\n predi...
252
1
from sklearn.metrics import mean_squared_error import datasets __UpperCAmelCase = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
367
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers...
139
0
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_available,...
29
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL lowercase_ = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def _snake_case( SCREAMING_SNAKE_CA...
7
0
"""simple docstring""" def UpperCamelCase_( _snake_case : int , _snake_case : int ): """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def UpperCamelCase_( ): """simple docstring""" ...
358
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency _lowerCAmelCase : Tuple = { "E": 12.70, "T": 9.06, "A": 8.17, "O": 7.51, "I": 6.97, "N": 6.75, "S": 6.33, "H": 6.09, "R": 5.99, "D": 4.25, "L": 4.03, "C"...
308
0