code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property f...
508
'''simple docstring''' def __snake_case ( lowercase : int = 1_000_000 ): snake_case_ = set(range(3 , lowercase , 2 ) ) primes.add(2 ) for p in range(3 , lowercase , 2 ): if p not in primes: continue primes.difference_updat...
508
1
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' a_ = """""" a_ = ...
27
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig fr...
27
1
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging __A ={ '''cola''': 2, '''mnli''...
463
import re def lowerCamelCase_ ( lowerCamelCase__ ): return [char.split() for char in re.split(r"[^ a-z A-Z 0-9 \s]" , str_ )] def lowerCamelCase_ ( lowerCamelCase__ ): lowerCamelCase_ = split_input(str_ ) return "".join( ...
463
1
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
651
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow lowerCamelCase : List[Any] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ ...
651
1
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
185
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
0
'''simple docstring''' import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def lowerCAmelCase( a__ : Tuple ): '''simple docst...
704
'''simple docstring''' import fire from utils import calculate_rouge, save_json def lowerCAmelCase( a__ : List[str] , a__ : str , a__ : List[Any]=None , **a__ : Optional[Any] ): '''simple docstring''' lowerCamelCase__ ...
426
0
import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer _lowerCamelCase : Any = l...
429
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class __snake_case : lowerCAmelCase__ = 42 lowerCAmelCase__ = None ...
429
1
snake_case_ : int =[ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audi...
718
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): ...
205
0
'''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 lowerCamelCase_ = logging.get_logger(__name__) cla...
418
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class lowercase ( unittest.TestCase ): """simple docstring"...
165
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https:...
34
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker...
34
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, ...
585
'''simple docstring''' class _lowerCAmelCase : '''simple docstring''' def __init__(self , UpperCAmelCase , UpperCAmelCase ) -> Any: _snake_case = name _snake_case = val def __str__(self ) -> List[str]: return...
585
1
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class UpperCAmelCase__ ( A_ ): """simple docstring""" UpperCAmelCase__ : Union[str, Any] = "" UpperCAmelCase__ : s...
682
import math from collections.abc import Callable def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : Callable[[float], float] , SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : float ): __UpperCamelCase =xa __UpperCamelCase =xa ...
682
1
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf ...
234
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __magic_name__ ( __UpperCAmelCase): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = "Speech2TextFeatureExtractor" SCREAMIN...
234
1
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( snake_case_ : int , snake_case_ : int ) -> str: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) SCREAMING_SNAKE_CASE : Optional[Any] = str(bin(snake_c...
220
'''simple docstring''' from pathlib import Path import numpy as np from PIL import Image def SCREAMING_SNAKE_CASE_ ( snake_case_ : np.ndarray ) -> np.ndarray: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Optional[Any] ...
220
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizer...
578
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
562
0
'''simple docstring''' import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
706
'''simple docstring''' import doctest from collections import deque import numpy as np class UpperCAmelCase_ : def __init__( self): snake_case_ : List[Any] = [2, 1, 2, -1] snake_case_ : int = [1, 2, 3, 4] def snake_case__ ( self): snak...
92
0
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stabl...
42
"""simple docstring""" from collections.abc import Callable import numpy as np def a ( __snake_case : Callable, __snake_case : float, __snake_case : float, __snake_case : float, __snake_case : float ): '''simple docstring''' UpperCAmelCase_ ...
608
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _A = { 'configuration_blip': [ 'BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BlipConfig', 'BlipTex...
403
# 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 # # Unless required by applic...
403
1
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 ModelTesterMixin, ids_tensor f...
197
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __A ( _A , _A ): """simple docstring""" _...
197
1
"""simple docstring""" import numpy as np import qiskit def __lowerCAmelCase( __UpperCAmelCase = 8 ,__UpperCAmelCase = None ): """simple docstring""" _lowercase : Any = np.random.default_rng(seed=snake_case__ ) # Roughly 25% of the qubits will contribute to th...
717
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_chan...
283
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEnc...
63
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distribut...
651
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-b...
707
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time UpperCAmelCase_ = Lock() def __magic_name__ ( lowercase , lowercase , lowercase , lowercase , lowerc...
436
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase: str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAv...
20
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def a_ ( lowerCAmelCase_ : Optional[Any], lowerCAmelCase_ : List[Any], lowerCAmelCase_ : str ...
53
0
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging _snake_case = { ...
231
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 UpperCAmelCase_ ( unittest.TestCa...
231
1
import math def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase ) -> Optional[Any]: if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(_UpperCAmelCase ) else: if x == 0: # 0 rais...
562
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowercase_ ...
562
1
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class __snake_case : def __init__( self : Tuple , __lowerCAmelCase : Any , __lowerCAmelCase : Tuple ): """simple docstring""" if len(lowerCamel...
710
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia ...
598
0
import os import pytest from attr import dataclass lowercase_ = 'us-east-1' # defaults region @dataclass class __lowerCAmelCase : _a = 42 _a = """arn:aws:iam::558105141721:role/sagemaker_execution_role""" _a = { """task_name""": """mnli...
291
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging lowercase_ ...
291
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _a ( _UpperCAmelCase ): '''simple docstring''' def __UpperCAmelCase( self , __UpperCAmelCase ): return 0.0 d...
702
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
387
0
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common...
249
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging UpperCamelCase__ ={ 'cola': 2, ...
249
1
"""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() except Optional...
244
"""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.apache.org/licenses/LICENS...
244
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def UpperCAmelCase_ ( _A , _A=False ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = OmegaConf.load(lowercase_ ) if display: prin...
493
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
462
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowercase__ ( metaclass=snake_case_ ): '''simple docstring''' _snake_case = ['''keras_nlp'''] def __init__( self , *lowerCamelCase__ , **lowerCamelCase...
715
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class lowercase__ ( tf.keras.layers.Layer ): '''simple docstring''' def __init__( self , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , low...
350
0
"""simple docstring""" def lowercase_ ( _snake_case ,_snake_case ): return 1 if input_a == input_a else 0 def lowercase_ ( ): assert xnor_gate(0 ,0 ) == 1 assert xnor_gate(0 ,1 ) == 0 assert xnor_gate(1 ,0 ) == 0 assert xnor_gate(1 ,1 ) == 1 i...
223
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCAmelCase__ : List[str] = logging.get_logger(__name__) class lowerCAmelCase_ (a__ ): """simple docstring""" ...
223
1
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __UpperCAmelCase = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __UpperCAmelCase = [file for file in filepaths if file != ...
708
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mobil...
218
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils ...
69
from sklearn.metrics import recall_score import datasets a_ :int = '\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives and FN is the false negatives.\n' a...
35
0
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase = 0 ): __snake_case : Dict = length or len(__lowerCamelCase ) __snake_case : Dict = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: ...
203
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTest...
203
1
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean _a : Tuple = 0 _a : str = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0,...
56
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer ...
217
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Optional[Any] = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab/lilt-rob...
191
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor a : str = logging.get_logger(__name__) class a ( lowercase__ ): """simple docstring""" def __init__( self : Optional[Any] , *_...
63
from ...configuration_utils import PretrainedConfig from ...utils import logging a : Tuple = logging.get_logger(__name__) a : List[str] = {"openai-gpt": "https://huggingface.co/openai-gpt/resolve/main/config.json"} class a ( lowercase__ ): ...
63
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_a...
47
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation Up...
47
1
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, ...
572
"""simple docstring""" import os import re 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 lowercase_ : List[str] = logging.g...
572
1
from __future__ import annotations def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): __lower...
53
import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase : str = logging.get_logger(_...
53
1
def lowerCamelCase_ ( _UpperCamelCase ) -> Any: """simple docstring""" snake_case_ : Dict = [] snake_case_ : int = set({'''(''', '''[''', '''{'''} ) snake_case_ : Dict = set({''')''', ''']''', '''}'''} ) ...
60
'''simple docstring''' class lowerCAmelCase : def __init__( self : List[Any] , __lowercase : str , __lowercase : Any , __lowercase : str ): """simple docstring""" __lowercase =name __lowercase ...
119
0
'''simple docstring''' def __snake_case ( UpperCAmelCase_ : str ): if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) lowerCamelCase_ = sorted(string.lower() ) return len(UpperCAmelCase_ ) == len(set(UpperCA...
708
'''simple docstring''' 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 __snake_case ( UpperCAmelCas...
445
0
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : Optional[int] = logging.get_logger(__name__) UpperCamelCase_ : Optional[Any] = { """huggingface/time-series-transformer-tourism...
461
from __future__ import annotations import unittest from transformers import 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, random_attention_mask from ...test_pipeline...
461
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[int] = logging.get_logger(__name__) _lowerCamelCase : Tuple = { '''microsoft/biogpt''': '''https://huggingface.co/microsoft/biogpt/resolve/main/config.json''', # See a...
647
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import C...
647
1
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from .....
59
'''simple docstring''' # Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the c...
407
0
from __future__ import annotations from fractions import Fraction def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def UpperCAmelCase ( _lowerCamelCase ...
17
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py __SCREAMING_SNAKE_CASE = """.""" if __name__ == "__main__": __SCREAMING_SNAKE_CASE = os.path.join(REPO_PATH, """utils...
17
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTokenizer _lowerc...
157
"""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.apache.or...
103
0
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def a__ ( _UpperCamelCase : Union[str, Any] ): if not is_accelerate_available(): return method __lowerCamelCase = version.parse(accelerate...
622
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 Accelerator from accelerate.t...
622
1
import unittest from transformers import DonutProcessor lowercase : Optional[int] = "naver-clova-ix/donut-base" class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" def __lowerCamelCase ( self ) -> Optional[int]: ...
327
# 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 # # Unless required by applica...
327
1
from __future__ import annotations def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) -> str: __snake_case: List[Any] = set(SCREAMING_SNAKE_CASE__), [start] while stack: __snake_case: int = stack.pop() explored.add(SCREAMING_SNAKE_C...
714
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def A__ ( ) -> Tuple: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname f...
155
0
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger __UpperCAmelCase = get_logger(__name__) __UpperCAmelCase = r'\n Args:\n input_ids (`jnp.nda...
65
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor _lowercase : List[str] = logging.get_logger(__name__) class UpperCamelCase__( lowerCAmelCase ): def __init__( self : str , *l...
210
0
"""simple docstring""" def A_ ( __UpperCamelCase : int = 10 , __UpperCamelCase : int = 22 ): lowercase = range(1 , __UpperCamelCase ) lowercase = range(1 , __UpperCamelCase ) return sum( 1 for power in powers for ba...
396
"""simple docstring""" def A_ ( __UpperCamelCase : str , __UpperCamelCase : str ): lowercase = len(__UpperCamelCase ) lowercase = [] for i in range(len(__UpperCamelCase ) - pat_len + 1 ): lowercase = True ...
396
1
__snake_case :Dict =8.31_4462 # Unit - J mol-1 K-1 def lowerCamelCase_ ( lowerCAmelCase__ : float , lowerCAmelCase__ : float , lowerCAmelCase__ : float ) -> float: '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: raise V...
106
"""simple docstring""" import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import tran...
543
0
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _UpperCamelCase = { "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, "num_class_embeds": 1000, "block_out...
706
from __future__ import annotations import typing from collections import Counter def _lowercase ( lowercase__ ): __lowerCAmelCase : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(lowercase__ , max...
583
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __magic_name__ : Tuple = logging.get_logger(__name__) __magic_name__ : int = ...
280
"""simple docstring""" import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn ...
552
0
'''simple docstring''' import math class A : def __init__( self , snake_case_=0 ) -> Tuple: # a graph with Node 0,1,...,N-1 _a = n _a = [ [math.inf for j in range(0 , snake_case_ )] for i in range(0 , snake_ca...
691
'''simple docstring''' class A : def __init__( self ) -> List[str]: _a = 0 _a = 0 _a = {} def __lowerCAmelCase ( self , snake_case_ ) -> int: if vertex not in self.adjacency: ...
691
1
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def lowercase ( _a ,_a ,_a ) -> str: # Initialise PyTorch model UpperCAmelCase_: Any = R...
137
def lowercase ( _a ) -> int: if not isinstance(_a ,_a ) or number < 0: raise ValueError("Input must be a non-negative integer" ) UpperCAmelCase_: List[Any] = 0 while number: # This way we arrive at next set bit (next 1) instead of looping # through ea...
137
1
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : str = { '''facebook/encodec_24khz''': ''...
581
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE__ : Union[str, Any] = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLConf...
581
1
__a = [ 'Audio', 'Array2D', 'Array3D', 'Array4D', 'Array5D', 'ClassLabel', 'Features', 'Sequence', 'Value', 'Image', 'Translation', 'TranslationVariableLanguages', ] from .audio import Audio from .features import ArrayaD, ArrayaD, ArrayaD, Array...
97
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def snake_case_ ( lowercase__ ): return x + 2 class UpperCAmelCase_ ( unittest.TestCase ): '''simple docstring''' ...
199
0
from __future__ import annotations from typing import TypedDict class lowerCAmelCase ( __snake_case ): UpperCAmelCase__ = 42 UpperCAmelCase__ = 42 def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> Optional[int]: if not isinstance(lowercase__ , lowercase__ ...
702
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, ...
188
0
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import req...
52
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffu...
527
0
from __future__ import annotations snake_case : Optional[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def __init__( self : ...
182
from __future__ import annotations snake_case : Optional[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCAmelCase__ : def __init__( self : ...
182
1
import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowerCAmelCase ( _UpperCamelCase : Any , _UpperCamelCase : str , _UpperCamelCase :...
439
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
439
1
__lowerCAmelCase = { '''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_ ( snake_case ...
707
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFXLMRobertaM...
335
0
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging A = loggi...
77
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mode...
77
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = { '''configuration_jukebox''': [ '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''JukeboxConfig''', '''JukeboxPriorConfig'...
143
from math import pow def UpperCAmelCase__ ( _A , _A , _A , _A , _A , ): """simple docstring""" if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 r...
143
1
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.c...
377
__a = 256 # Modulus to hash a string __a = 100_0003 def _UpperCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ) ->bool: UpperCAmelCase = len(lowerCAmelCase_ ) UpperCAmelCase = len(lowerCAmelCase_ ) if p_len > t_len: return False UpperCAmelC...
377
1
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class SCREAMING_SNAKE_CASE ...
62
def __A ( _lowercase = 1_00_00_00 ): '''simple docstring''' _A = 1 _A = 1 _A = {1: 1} for inputa in range(2 , _lowercase ): _A = 0 _A = inputa while True: if number in counters: ...
62
1
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _snake_case ( UpperCAmelCase_ ): __lowerCAmelCase : Optional[int] = (CMStochasticIterativeScheduler,) __lowerCAmelCase : int = 10 def lowercase...
12
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
12
1
'''simple docstring''' from math import sqrt def _UpperCamelCase ( __A ) -> Dict: '''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, al...
714
'''simple docstring''' import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def _UpperCamelCase ( __A , __A , __A ) -> Tuple: '''simple docstring''' UpperCamelCase__ = AutoConfig.from_pretrain...
223
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase :Dict = { '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''LongT5...
667
'''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 _lowerCAmelCa...
667
1
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testi...
709
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.tes...
167
0
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def lowerCamelCase_ ( UpperCamelCase__ : str ) -> None: """simple docstring""" __lowerCamelCase , __lowerCamelCase = ...
469
from sklearn.metrics import mean_squared_error import datasets __A = "\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirion, B. and Grisel, O. and Blondel, M. and Pret...
469
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE : str = { """configuration_longformer""": [ """LONGFORMER_PRETRAINED_CONFI...
525
from __future__ import annotations class A_ : def __init__( self : Union[str, Any] , __SCREAMING_SNAKE_CASE : int ): __a = order # a_{0} ... a_{k} __a = [1.0] + [0.0] * order # b_{0} ... b_{k} __a = [1.0] + [0.0] * order # x[n-1] ... x...
525
1
"""simple docstring""" from __future__ import annotations import typing from collections.abc import Iterable import numpy as np A_ = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 A_ = typing.Union[np.floataa, int, float] # noqa: UP007 def lowercase ...
29
'''simple docstring''' from collections import Counter from timeit import timeit def _lowerCAmelCase ( lowercase = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(""" """ , """""" ).lower() ).values() ) < 2 def _lowerCAmelCase ( lowe...
689
0
'''simple docstring''' from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_...
709
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowercase__ ( __UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : bool = False ): ...
339
0
__A = tuple[float, float, float] __A = tuple[float, float, float] def lowerCAmelCase_ ( __a , __a ) -> Vectorad: """simple docstring""" lowerCamelCase__: Optional[int] =end_pointa[0] - end_pointa[0] lowerCamelCase__: Any ...
59
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer ...
477
0
"""simple docstring""" import os def _lowerCAmelCase ( ) ->List[str]: with open(os.path.dirname(UpperCAmelCase__ ) + """/grid.txt""" ) as f: A__ : str = [] # noqa: E741 for _ in range(2_0 ): l.append([int(UpperCAmelCase...
498
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __SCREAMING_SN...
498
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_co...
660
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availabl...
660
1
"""simple docstring""" __A : List[Any] = [0, 2, 4, 6, 8] __A : List[Any] = [1, 3, 5, 7, 9] def lowercase ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : List[str] , _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAK...
719
"""simple docstring""" 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, s...
95
0
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenizat...
369
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoToke...
647
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vis...
477
"""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_utils import replicate ...
477
1
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase_ = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MA...
498
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __lowerCamelCase ( a_ : Dict ) -> Union[str, Any]: __SCREAMING_SNAKE_CASE :Optional[int] = os.p...
498
1
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/data2vec-vision-base-ft": ( "https:/...
279
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipelin...
279
1
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> Dict: '''simple docstring''' if "img_encoder.pos...
567
"""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.apache.org/licenses/L...
567
1
'''simple docstring''' a : int = [0, 2, 4, 6, 8] a : Any = [1, 3, 5, 7, 9] def __UpperCAmelCase ( _UpperCAmelCase : Optional[Any] , _UpperCAmelCase : Dict , _UpperCAmelCase : Optional[Any] , _UpperCAmelCase : Dict ) -> i...
713
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
0
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_avai...
155
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = [] create_all_state(1 , UpperCamelCase_ , UpperCamelCase_ , [] , UpperCamelCase_ ) re...
155
1
import torch from transformers import AutoModel class _UpperCAmelCase ( torch.nn.Module ): """simple docstring""" def __init__( self : str , lowerCAmelCase_ : str="sayef/fsner-bert-base-uncased" ) -> Optional[Any]: super(lowerCAmelCase_ , ...
421
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a_ ( lowerCAmelCase_ : List[Any] ): __lowerCAmelCase = [ 'decoder.version', 'decoder.output_projection.weight', '_floa...
421
1
from __future__ import annotations import math def _snake_case ( __snake_case ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ...
10
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_...
21
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "facebook/timesformer": "https://huggingface.co/facebook/timesformer/resolve/main/config.json", } class SCREAM...
63
"""simple docstring""" import os def __magic_name__ ( _lowerCamelCase : Dict ): __a : List[str] = len(grid[0] ) __a : int = len(_lowerCamelCase ) __a : Tuple = 0 __a : List[Any] = ...
63
1
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _lowerCAmelCase( UpperCAmelCase_ , un...
57
"""simple docstring""" import os def SCREAMING_SNAKE_CASE__ ( )-> Optional[Any]: '''simple docstring''' with open(os.path.dirname(snake_case ) + "/p022_names.txt" ) as file: UpperCAmelCase__ : Tuple = str(file.readlines()[0] ) Uppe...
438
0
'''simple docstring''' def lowercase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _snake_case : str = str(bin(SCREAMING_SNA...
706
import argparse import os import re a__ = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a__ = re.compile(R"""[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict""") # re patte...
198
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForS...
41
'''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.apache.org/licenses/LICENSE-...
41
1
"""simple docstring""" from __future__ import annotations def lowercase ( UpperCamelCase : int , UpperCamelCase : int ): """simple docstring""" if b == 0: return (1, 0) ((A__) , (A__)) : Union[str, Any] =extended_euclid(UpperCamelCase ...
595
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class __lowerCAmelCase ( nn.Module): '''simple docstring''' def __init__( self : Union[str, Any] , UpperCamelCase__ ...
595
1
'''simple docstring''' from __future__ import annotations def _A ( A__ , A__ , A__ ): """simple docstring""" __lowercase = list(range(len(A__ ) ) ) __lowercase = [v / w for v, w in zip(A__ , A__ )] index.sort(key=lambda A__ : ratio[i] , re...
41
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class lowercase_ (lowerCamelCase__ ): ...
41
1
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() __lowerCamelCase : Optional[int] = [ ''...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Optional[int] = logging.get_logger(__name__) __lowerCamelCase : str = { '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.jso...
379
0
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transforme...
67
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging...
442
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
80
import os from collections.abc import Iterator def lowerCamelCase__ ( A__ : str = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(A__ ): __lowerCamelCase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] ...
80
1