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
"""simple docstring""" import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ = logging.get_logger(_...
78
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...sch...
78
1
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_avail...
157
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin fr...
157
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor A__ : int =logging.get_logger(__name__) class UpperCAmelCase ( snake_case_ ): def __init__( self : List[str...
70
'''simple docstring''' 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 classe...
185
0
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_a ) class _A ( _a ): """simple docstring""" UpperCA...
226
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConf...
226
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A: Tuple = {"configuration_encoder_decoder": ["EncoderDecoderConfig"]} try: if not is_torch_av...
109
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_to...
148
0
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def __UpperCAmelCase ( __lowerCamelCase ) -> Any: lowercase__ : List[str] = {} ...
355
"""simple docstring""" import faiss # 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 requests # noqa: F401 # Here to have a nice missing dependency error message early...
302
0
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=lo...
98
"""simple docstring""" import functools def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = len(lowerCamelCase ) UpperCAmelCase__ = len(lowerCamelCase ) @functools.cache def min_distance(lowerCamelCase , lo...
98
1
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. snake_case : str = 10 def __lowerCamelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int , Upp...
360
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...tes...
281
0
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _lowerCAmelCase (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = None): if version.parse(hfh.__version__).release < version.parse("0.11.0").release: ...
128
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDI...
82
0
def A_ ( _UpperCAmelCase = 4_00_00_00 ): SCREAMING_SNAKE_CASE_: Optional[int] = [0, 1] SCREAMING_SNAKE_CASE_: Union[str, Any] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 S...
127
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase : Optional[int] = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} try:...
127
1
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor lowerCAmelCase__ : List[Any] =logging.get_logger(__name__) class UpperCAmelCase_ ( UpperCamelCase_ ): '''simple docstring''' def __init__( self , *_A ...
257
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ : Optional[Any] ={ '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2C...
257
1
"""simple docstring""" from collections import defaultdict from math import gcd def lowerCAmelCase_( lowercase_ : int = 1_50_00_00 ) -> Dict: _lowerCamelCase = defaultdict(lowercase_ ) _lowerCamelCase = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: ...
371
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : List[str] = { '''configuration_vision_encoder_decoder''': ['''Vis...
73
0
import argparse import os import re __UpperCAmelCase = "src/transformers" # Pattern that looks at the indentation in a line. __UpperCAmelCase = re.compile(R"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. __UpperCAmelCase = re.compile(R"^\s*\"([^\"]+)\":") # Pattern tha...
299
import functools from typing import Any def UpperCamelCase ( snake_case__ : str , snake_case__ : list[str] ) -> bool: # Validation if not isinstance(snake_case__ , snake_case__ ) or len(snake_case__ ) == 0: raise ValueError('the string should be not empty s...
119
0
'''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 AutoI...
359
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCAmelCase_ = Lock() def __magic_name__ ( A , A , A , A , A , A , A ) -> Any: global process_lock...
332
0
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention fro...
304
'''simple docstring''' def __UpperCAmelCase ( A : int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence UpperCAmelCase_ : int = gr...
304
1
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __lowerCAmelCase = logging.get_logger(__name__) class __a ( __UpperCamelCase ): def __init__( self , *lowerCAmelCase__ , **lowerCAmelCas...
355
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inpu...
288
0
'''simple docstring''' import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING Upp...
23
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_...
23
1
"""simple docstring""" A = { "km/h": 1.0, "m/s": 3.6, "mph": 1.609344, "knot": 1.852, } A = { "km/h": 1.0, "m/s": 0.277777778, "mph": 0.621371192, "knot": 0.539956803, } def __A ( a_ :float , a_ :str , a_ ...
188
"""simple docstring""" def __A ( a_ :int = 1_00_00_00) -> int: __a : Tuple = [i - 1 for i in range(limit + 1)] for i in range(2 , limit + 1): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , a_): ...
188
1
from maths.prime_factors import prime_factors def lowerCAmelCase__( lowercase : int ) -> int: if not isinstance(lowercase , lowercase ): __snake_case : Optional[int] = f"""Input value of [number={number}] must be an integer""" raise TypeError(lowercase ) i...
326
def lowerCAmelCase__( lowercase : list[int] , lowercase : int ) -> bool: __snake_case : List[str] = len(lowercase ) __snake_case : int = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed ...
326
1
'''simple docstring''' from __future__ import annotations UpperCamelCase = list[list[int]] # assigning initial values to the grid UpperCamelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0...
334
'''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 fro...
334
1
'''simple docstring''' from math import pi def A__ ( UpperCAmelCase_ , UpperCAmelCase_ ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
83
'''simple docstring''' def _lowercase ( __A ,__A ): '''simple docstring''' __UpperCamelCase = len(__A ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by no...
349
0
"""simple docstring""" UpperCAmelCase =256 # Modulus to hash a string UpperCAmelCase =1_000_003 def _A ( _a : str , _a : str ): """simple docstring""" A = len(_a ) A = len(_a ...
369
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class lowerCamelCase__ ( SCREAMING_SNAKE_CASE ): ...
77
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a_ :Any = { "configuration_mvp": ["MVP_PRETRAINED_CONFIG_ARCHIVE_MAP", "MvpConfig", "MvpOnnxConfig"], "tokenization_mvp": ["MvpTokenizer"], } try: ...
277
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ :Optional[Any] = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConf...
277
1
def __UpperCAmelCase ( __a : int ) -> int: """simple docstring""" if n == 1 or not isinstance(__a ,__a ): return 0 elif n == 2: return 1 else: _a : Any = [0, 1] for i in range(2 ,n + 1 ...
15
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_uti...
15
1
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration UpperCamelCase_ = 5_0_0_0_0 UpperCamelCase_ = 5_0_0_0 UpperCamelCase_ , UpperCamelCase_ = os.path.split(__file__)...
251
'''simple docstring''' from pathlib import Path import numpy as np from PIL import Image def lowercase__( __UpperCamelCase: np.ndarray ): """simple docstring""" SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[Any] ...
251
1
'''simple docstring''' from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils imp...
352
'''simple docstring''' def _UpperCAmelCase ( _UpperCamelCase : Union[str, Any] ) -> Dict: A_ = 1 A_ = 2 while i * i <= n: A_ = 0 while n % i == 0: n //= i multiplicity += 1 n_divisor...
18
0
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def A_ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: int = AutoConfig.from_pretrained(_UpperCAmelCase ) SCREAMING_SNAKE_CASE...
13
class __lowercase : """simple docstring""" def __init__( self : List[Any] , lowerCAmelCase__ : Optional[int] , lowerCAmelCase__ : List[Any]): SCREAMING_SNAKE_CASE_: List[str] = name SCREAMING_SNAKE_CASE_: Union[str, Any] = val ...
13
1
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ :Dict = logging.get_logger(__name__) lowercase__ :Optional[Any] = "▁" lowercase__ :str = ...
97
from pathlib import Path import fire from tqdm import tqdm def UpperCamelCase ( lowerCAmelCase__="ro" , lowerCAmelCase__="en" , lowerCAmelCase__="wmt16" , lowerCAmelCase__=None ): '''simple docstring''' try: import datasets except (ModuleNotFoundError, Import...
97
1
"""simple docstring""" import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_rea...
40
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __lowerCAmelCase : Any = (3, 9, -11, 0, 7, 5, 1, -1) __lowerCAmelCase : Tuple = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __lowerCAmelCase : """...
156
0
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, ...
281
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...ut...
281
1
__lowercase = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_0000)] def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Tuple = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum...
43
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json''',...
43
1
"""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 fro...
30
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCAmelCase__ = argparse.ArgumentParser() parser.add_argument("""--dump_path""", de...
30
1
"""simple docstring""" import cva import numpy as np class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : str ,lowercase_ : float ,lowercase_ : int ): if k in (0.04, 0.06): lowerCAmelCase__ : Optional[Any] = k...
106
import random from typing import Any def UpperCamelCase_( lowerCamelCase_ ) -> list[Any]: for _ in range(len(lowerCamelCase_ ) ): _lowercase : Optional[int] = random.randint(0 , len(lowerCamelCase_ ) - 1 ) _lowercase : str = random...
21
0
'''simple docstring''' import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def snake_case__ ( lowerCamelCase__ : Optional[int] , lowerCamelCase__ : List[...
354
'''simple docstring''' from __future__ import annotations def snake_case__ ( lowerCamelCase__ : list[int] , lowerCamelCase__ : int ) -> list[int]: A_ : int = 0 A_ : str = len(lowerCamelCase__ ) - 1 while i < ...
4
0
'''simple docstring''' import numpy as np import datasets A_ : str = "\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt w...
215
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __A ( ) -> Any: a = ArgumentParser( description=( """PyTorch TPU distributed training ...
228
0
"""simple docstring""" import math class UpperCamelCase_ : """simple docstring""" def UpperCAmelCase_ ( self : Any , UpperCAmelCase__ : int , UpperCAmelCase__ : int ) -> int: __SCREAMING_SNAKE_CASE = 0.0 ...
350
"""simple docstring""" import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, float...
195
0
'''simple docstring''' from __future__ import annotations __lowercase = '''#''' class a__: '''simple docstring''' def __init__( self): """simple docstring""" lowerCAmelCase = {} def a_ ( self , __lowerCAmelCase): """...
272
'''simple docstring''' from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig __lowercase = logging.get_logger(__name__) __lowercase = '''T5Config''' class a__( lowerCAmelCas...
272
1
import functools from typing import Any def lowerCAmelCase_ ( __A, __A ) -> bool: '''simple docstring''' if not isinstance(__A, __A ) or len(__A ) == 0: raise ValueError("the string should be not empty string" ) ...
143
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline,...
143
1
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union 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 if is_torch_available(): import torch l...
104
'''simple docstring''' import unittest from transformers import DebertaConfig, 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 ModelT...
104
1
"""simple docstring""" import requests def _snake_case ( UpperCamelCase : str , UpperCamelCase : str ): UpperCAmelCase : Any = {"""Content-Type""": """application/json"""} UpperCAmelCase : int = requests.post(UpperCamelCase , json={"""text""": me...
76
"""simple docstring""" def _snake_case ( UpperCamelCase : int , UpperCamelCase : int ): return number | (1 << position) def _snake_case ( UpperCamelCase : int , UpperCamelCase : int ): return number & ~(1 << position) def _snake_case ...
76
1
'''simple docstring''' import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig ...
85
'''simple docstring''' from __future__ import annotations import requests def UpperCamelCase_( snake_case : str ): '''simple docstring''' snake_case_ = f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' return requests.get(s...
85
1
"""simple docstring""" # Copyright (c) 2021-, NVIDIA CORPORATION. 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/LICENS...
272
"""simple docstring""" def snake_case__ ( __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : List[Any] =[0] * len(__lowerCamelCase ) lowerCamelCase__ : List[Any] =[] lowerCamelCase__ : List[Any] =[1] * len(__lowerCamelCase ) ...
272
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", } class a__ ( snak...
92
from functools import lru_cache @lru_cache def _snake_case ( lowerCAmelCase : int ): """simple docstring""" if num < 0: raise ValueError("Number should not be negative." ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doct...
18
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Dict= logging.get_logger(__name__) _a : Tuple= { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCamelCase ( ...
95
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: '''simple docstring''' while a != 0: __snake_case , __snake_case : Union[str, Any] = b % a, a return b def __UpperC...
95
1
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_...
132
import os import pytest from attr import dataclass lowerCamelCase = 'us-east-1' # defaults region @dataclass class A : UpperCamelCase__ : str UpperCamelCase__ : Dict ='arn:aws:iam::558105141721:role/sagemaker_execution_role' UpperCamelCase__ : int ...
199
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'uw-madison/mra-base-512-4': 'https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json', } class __S...
350
'''simple docstring''' from decimal import Decimal, getcontext from math import ceil, factorial def _a( UpperCamelCase__ : int ): '''simple docstring''' if not isinstance(UpperCamelCase__, UpperCamelCase__ ): raise TypeError(...
222
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A =logging.get_logger(__name__) A ={ 'facebook/levit-128S': 'ht...
34
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def UpperCamelCase_( snake_case : Any ): '''simple docstring''' if ( (cp >= 0X4E00 and cp...
85
0
import argparse import json from tqdm import tqdm def a__ ( ) -> List[str]: UpperCAmelCase__ : Any = argparse.ArgumentParser() # Required parameters parser.add_argument( """--src_path""" , type=_a , default="""biencoder-nq-dev.json""" , help="""Pat...
365
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } class lowerCamelCase ( lower...
166
0
"""simple docstring""" from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : int = c...
86
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pr...
86
1
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel lowerCAmelCase__ = False lowerCAmelCase__ = True lowerCAmelCase__ = False if __name__ == "__main__": lowerCAmelCase__ = argpar...
121
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 lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = '''▁''' lowerCAm...
121
1
"""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...
264
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ) ->bool: """simple docstring""" a_ = set() # Replace all the whitespace in our sentence a_ = input_str.replace(" " , "" ) for alpha in input...
243
0
'''simple docstring''' from collections.abc import Sequence def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__ ) -> float: return sum(c * (x**i) for i, c in enumerate(UpperCAmelCase__ ) ) def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__ ) -> floa...
357
'''simple docstring''' from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, requi...
101
0
"""simple docstring""" from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _UpperCamelCase : str = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _UpperCamelCase : Tuple = typing.Union[np.floataa, int, float] # n...
220
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _lowerCamelCase : str = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _lowerCamelCase : Tuple = typing.Union[np.floataa, int, float] # noqa: UP007 ...
14
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Union[str, Any] = { '''configuration_longformer...
79
"""simple docstring""" import math def _SCREAMING_SNAKE_CASE ( _lowercase : int = 100 ) ->int: '''simple docstring''' a : Dict = sum(i * i for i in range(1 , n + 1 ) ) a : Tuple = int(math.pow(sum(range(1 , n + 1...
79
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, TrainingArguments f...
20
def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> List[str]: if index == r: for j in range(SCREAMING_SNAKE_CASE__ ): prin...
20
1
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_commo...
123
'''simple docstring''' 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 data...
123
1
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__ : Dict = {'''configuration_m...
187
import math class _snake_case : def __init__( self , _lowerCamelCase=0 ): # a graph with Node 0,1,...,N-1 a :Optional[int] = n a :Union[str, Any] = [ [math.inf for j in range(0 , _lowerCamelCase )] for i in range(0 , _...
94
0
"""simple docstring""" import random def _a ( _snake_case , _snake_case , _snake_case ): """simple docstring""" UpperCAmelCase = a[left_index] UpperCAmelCase = left_index + 1 for j in range(left_index + 1 , _snake_case ): ...
364
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _UpperCamelCase = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_visio...
234
0
import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig if TYPE_CHECKING: from ... import ...
209
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py a__ = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic Evaluation ...
235
0
'''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/LICENSE-2.0 ...
61
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'google/pix2struct-textcaps-base': ( 'https://huggingface.co/goog...
61
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass snake_case_ = (3, 9, -11, 0, 7, 5, 1, -1) snake_case_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class SCREAMING_SNAKE_CASE__ : __lowerCamelCase : Any = ...
214
from __future__ import annotations def _a ( lowerCamelCase: list[float] , lowerCamelCase: Tuple ) -> List[str]: '''simple docstring''' print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(lowerCamelCase ): ...
117
0
import functools def a_ ( __lowercase : list[int] , __lowercase : list[int] ) -> int: # Validation if not isinstance(__lowercase , __lowercase ) or not all(isinstance(__lowercase , __lowercase ) for day in days ): raise ValueError('The parameter days should be a list...
353
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) _lowerC...
130
0
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowercase__ : Any = argparse.ArgumentParser( description=( """Extraction some layers of the full Robert...
224
"""simple docstring""" import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging lowercase__ : Optional[Any] = logging.get_logger(__name__) ...
224
1
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def UpperCamelCase_( *snake_case : Dict , snake_case : Optional[Union[Dict, Any]] = None , snake_case : List[str]=True , sn...
360
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention...
92
0
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def lowercase () -> Any: '''simple docstring''' lowerCAmelCase = { """repo_name""": ["""...
155
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : str ) -> str: '''simple docstring''' return " ".join( "".join(word[::-1] ) if len(__lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": im...
22
0
"""simple docstring""" from __future__ import annotations def _a ( _snake_case , _snake_case , _snake_case ): """simple docstring""" if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0""" ...
234
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _UpperCamelCase = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn"...
234
1
from math import factorial class a__ : def __init__( self : List[str],_A : Tuple,_A : int ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = real if isinstance(_A,_A ): SCREAMING_SNAKE_...
18
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import logging l...
334
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'xlm-mlm-en-2048': 'https://h...
358
class SCREAMING_SNAKE_CASE__ : def __init__(self : str , a__ : list ): """simple docstring""" __snake_case = set_counts __snake_case = max(a__ ) __snake_case = len(a__ ) ...
238
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : List[Any] = { """configuration_vision_encoder_decoder""": ["""Visio...
31
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, ini...
25
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration UpperCAmelCase_ : Tuple = 5_00_00 UpperCAmelCase_ : int = 50_00 UpperCAmelCase_ , UpperCAmelCase_ : Tuple = os.path.split(__file__) UpperCAmelCase_ : ...
62
from string import ascii_lowercase, ascii_uppercase def SCREAMING_SNAKE_CASE_ ( __magic_name__ : str ) -> str: """simple docstring""" if not sentence: return "" UpperCamelCase :str = dict(zip(__magic_name__ , __magic_name__ ) ) return lower_to_u...
62
1
'''simple docstring''' from collections.abc import Callable import numpy as np def a_ ( lowerCamelCase : Callable , lowerCamelCase : float , lowerCamelCase : float , lowerCamelCase : float , lowerCamelCase : float ): lowerCAmelCase = int(np.ceil((x_end ...
4
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_se...
4
1
import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", exist_ok=True) def __UpperCamelCase ( _l...
370
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
115
0
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class __lowerCamelCase : '''simple docstring''' A_ : float A_ : TreeNode | None = None A_ : TreeNode | None = None def A_ ( _lowe...
320
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __A : Dict = ''' Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that ...
33
0
"""simple docstring""" def _lowerCamelCase( a ): if num < 0: return False __a = num __a = 0 while num > 0: __a = rev_num * 1_0 + (num % 1_0) num //= 1_0 return num_copy == rev_num if __name__ ==...
359
"""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 from...
268
0
import math _UpperCAmelCase : List[Any] = 10 _UpperCAmelCase : List[str] = 7 _UpperCAmelCase : Dict = BALLS_PER_COLOUR * NUM_COLOURS def A ( lowercase = 20 ) -> str: '''simple docstring''' UpperCamelCase = math.comb(lowercase , lower...
222
def A ( lowercase , lowercase , lowercase , lowercase , lowercase ) -> int: '''simple docstring''' if index == number_of_items: return 0 UpperCamelCase = 0 UpperCamelCase = 0 UpperCamelCase = knapsack(lowercase , lowercase ...
222
1
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = 1000 ) -> int: '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
83
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_...
83
1
'''simple docstring''' import argparse from collections import defaultdict import yaml lowerCamelCase : Optional[Any] = 'docs/source/en/_toctree.yml' def _SCREAMING_SNAKE_CASE (A ) -> List[Any]: """simple docstring""" lowercase__ = default...
2
"""simple docstring""" def lowercase ( a__ : Union[str, Any] ) -> Optional[Any]: _UpperCamelCase = len(a__ ) while cur > 1: # Find the maximum number in arr _UpperCamelCase = arr.index(max(arr[0:cur] ) ) # Reverse from 0 t...
256
0
'''simple docstring''' import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def _UpperCamelCase ( UpperC...
369
'''simple docstring''' 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...
283
0
"""simple docstring""" import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class UpperCamelCase_ ( UpperCamelCase): """simple docstring""" def __init__( self : Any , UpperCAmelCase__ ...
54
"""simple docstring""" from PIL import Image def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = image.size __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = image.load(...
54
1
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def SCREAMING_SNAKE_CASE( __lowercase , __lowercase ) -> Generator[tuple[str, ...], None, None]: A: List[str] = iter(__lowercase ) while True:...
334
'''simple docstring''' from __future__ import annotations from typing import Any class lowerCAmelCase_ ( UpperCAmelCase_ ): '''simple docstring''' pass class lowerCAmelCase_ : '''simple docstring''' def __init__( ...
334
1
'''simple docstring''' import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
56
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
264
0
from __future__ import annotations __UpperCAmelCase : Dict = 1.6_0_2_1e-1_9 # units = C def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , ) -> tuple[str, float]: if (conductivity, electron_conc, mobility).count(0) != 1: raise ...
293
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 .model...
293
1
"""simple docstring""" from __future__ import annotations class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: '''simple docstring''' UpperCAmelCase : Any = data UpperCAmelCase : Node | None = None UpperCAmelCase : ...
109
"""simple docstring""" from math import isqrt, loga def _snake_case ( UpperCamelCase : int ): UpperCAmelCase : Any = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase , UpperCamelCase ...
109
1
"""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_extract...
361
"""simple docstring""" import argparse import gc import json import os 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 fro...
168
0
def lowercase_ ( _lowerCamelCase : list[list[int]] , _lowerCamelCase : int , _lowerCamelCase : int , _lowerCamelCase : list[int]): # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: ...
87
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
0
"""simple docstring""" from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch('socket.socket' ) @patch('builtins.open' ) def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): # ===== initialization ===== lowerCamelCase__ : Opti...
316
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig fro...
316
1
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 ModelTesterMixin, ids_tensor fr...
257
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Fl...
257
1
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm i...
45
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase : List[str] = { """configuration_m2m_100""": ["""M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP""", """M2M100Config""", """M2M100OnnxConfig"...
45
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer from .tokeniza...
285
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, BaseModelOutputWithNoAttention, BaseModelOutputWithPoo...
285
1
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __lowerCamelCase ( __magic_name__ : str = "isbn/0140328726" ): a__: Tuple =olid.strip().strip("/" ) # Remove leading/trailing whitespace & slashes if new_olid.count...
365
from __future__ import annotations from math import gcd def __lowerCamelCase ( __magic_name__ : int , __magic_name__ : int = 2 , __magic_name__ : int = 1 , __magic_name__ : int = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm. ...
42
0
from ..utils import DummyObject, requires_backends class snake_case_ ( metaclass=__A ): __A : Tuple = ["speech"] def __init__( self : List[str] , *lowercase_ : Optional[Any] , **lowercase_ : str ) -> List[str]: r...
87
"""simple docstring""" import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers...
268
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def a__ ( _SCREAMING_SNAKE_CA...
353
"""simple docstring""" import math def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase = 0 UpperCamelCase = 0 while num > 0: UpperCamelCase = num % 8 UpperCamelCase = octal + (remainder * math.floor(math.pow(10 , _SCREAMING_SNAKE_CAS...
244
0
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Tuple: """simple docstring""" return base * power(lowercase_ , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print("""Raise base to the power of exponent using recursion...""") _lowerCa...
14
'''simple docstring''' from collections import UserDict 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_availab...
37
0
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 import cached_property from ...test_toke...
354
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _snake_case : Optional[Any] = {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FNetConfig...
207
0
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute...
199
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def _snake_case ( ) -> Generator[int, None, None]: '''simple docstring''' lowerCAmelCase_ :dict[int, int] = {} lowerCAmelCase_ :int ...
84
0
"""simple docstring""" from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline lowercase_ ...
11
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowercase_ = "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed...
11
1
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 UpperCAmelCase ( a_ , a...
15
def UpperCAmelCase ( a_ ) -> list: """simple docstring""" if len(a_ ) <= 1: return lst __A = 1 while i < len(a_ ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A = lst[i], lst[i - 1] i -= ...
15
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from ...
370
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ = { 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTokenizer'], ...
111
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_...
204
from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( IMAGENET_S...
204
1
"""simple docstring""" A: Dict = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def _snake_case ( UpperCamelCase : dict , UpperCamelCase : Optional[int] ...
76
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAK...
76
1