code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from ....
576
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, TokenC...
576
1
'''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...
471
'''simple docstring''' from __future__ import annotations from typing import Any class lowercase ( a_ ): pass class lowercase : def __init__( self , _snake_case) -> None: UpperCAmelCase_ : Any = data Up...
471
1
import argparse import copy def lowerCAmelCase_ ( lowerCamelCase ): __magic_name__ : Tuple ={} with open(lowerCamelCase ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __magic_name__ : Optiona...
21
'''simple docstring''' _UpperCAmelCase : Any = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def snake_case__ ( UpperCamelCase ) -> int: _UpperCamelCase : Any = 0 while number: # Increased Speed Slightly by checking every 5 digits together....
683
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class __lowercase ( UpperCamelCase__ ): def __init__( self : Any , *lowercase__ : U...
710
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCamelCase__ = (3, 9, -11, 0, 7, 5, 1, -1) UpperCamelCase__ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __lowercase : _lowerCAmelCase ...
143
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProces...
109
'''simple docstring''' from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) # TODO Update this a = { "facebook/esm-1b": "https://huggingface.co/facebook/esm-1b/re...
109
1
'''simple docstring''' 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 __A (UpperCamelC...
718
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, ...
10
0
'''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_comman...
28
def _UpperCamelCase ( snake_case__ ) -> str: __UpperCAmelCase : Tuple = int(snake_case__ ) if decimal in (0, 1): # Exit cases for the recursion return str(snake_case__ ) __UpperCAmelCase , __UpperCAmelCase : List[str] = divmo...
382
0
def lowercase ( a ): '''simple docstring''' if length <= 0 or not isinstance(a , a ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(a )] if __name__ == "__main__": print(hexagonal_numbers(length=5)) print(hexagonal_numbe...
140
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _UpperCAmelCase : def __init__( self : Tuple , UpperCAmelCase : Collection[float] | None = None): if components is None: SCREAMING_...
140
1
def lowerCAmelCase_ ( __a ) -> None: """simple docstring""" lowerCamelCase__: List[Any] =generate_pascal_triangle(__a ) for row_idx in range(__a ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ) # Print ...
59
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _...
156
0
def SCREAMING_SNAKE_CASE_ ( __A : int ) -> Optional[Any]: """simple docstring""" if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ): raise ValueError('multiplicative_persistence() only accepts integral values' ) if num <...
710
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
443
0
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 FlaxTimestepE...
33
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ : Union[str, Any] = logging.get_logger(__name__) lowercase_ : Any = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer...
572
0
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sq...
528
'''simple docstring''' from __future__ import annotations import time import numpy as np UpperCamelCase__: Tuple = [8, 5, 9, 7] UpperCamelCase__: int = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] Uppe...
528
1
"""simple docstring""" from typing import Any class a__ : def __init__( self : List[str] , UpperCamelCase_ : Any): """simple docstring""" __UpperCAmelCase : str = data __UpperCAmelCase : Optional[Any] = None ...
77
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() a : Optional[Any] = logging.get_logger(__name__) a : List[str] = {name: getattr(transformers, n...
679
0
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem _a : Optional[Any] = importlib.util.find_spec("s3fs") is not Non...
720
'''simple docstring''' def _lowercase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumer...
10
0
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def snake_case ( A__ ): UpperCAmelCase_ : int = int(number**0.5 ) return number == sq * sq def snake_case ( A__ ,A__ ,A__ ,A__ ,A__ ,A...
95
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def snake_case ( A__ ): UpperCAmelCase_ : int = int(number**0.5 ) return number == sq * sq def snake_case ( A__ ,A__ ,A__ ,A__ ,A__ ,A...
95
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A__ = logging.get_logger(__name__) A__ = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all PEGASUS models at https://huggi...
49
def _lowerCamelCase ( a_ : list): if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''') for cell_n in range(1 , len(grid[0])): grid[0][cell_n] += grid[0][cell_n - 1] lowerCamelCase :Any = grid[0] for ...
49
1
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __magic_name__ = TypeVar('''T''') class _SCREAMING_SNAKE_CASE ( Generic[T] ): def __init__( self , lowerCamelCase ): snake_case__ = data sna...
276
def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase ): if any(not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(__lowerCAmelCase ) ): for i, (rod_u...
276
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_co...
296
"""simple docstring""" from math import ceil def lowerCAmelCase (__UpperCamelCase : List[str] , __UpperCamelCase : Any ): """simple docstring""" __UpperCamelCase =list(range(0 , __UpperCamelCase ) ) __UpperCamelCase =[item for subli...
296
1
'''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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_...
284
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _snake_case ( a_ ): SCREAMING_SNAKE_CASE : Dict = (DDPMScheduler,) def _SCREAMING_SNAKE_CASE ( self , **_SCREAMING_SNAKE_CASE ): ...
284
1
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset 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 impo...
388
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_conf...
388
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A : Optional[Any] = { 'configuration_resnet': ['RESNET_PRETRAINED_CONFI...
516
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import On...
516
1
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging _A = logging.get_logger(__name__) def lowercase_ ...
294
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoMod...
294
1
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : List[Any] = { 'microsoft/wavlm-base': 'https://huggingface....
614
'''simple docstring''' import os from datetime import datetime as dt from github import Github UpperCamelCase__ : str = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def __UpperCamel...
614
1
"""simple docstring""" import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = r'\n Args:\n inp...
194
"""simple docstring""" import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils...
194
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class A( lowerCamelCase__ ): """simple docstring""" def __in...
355
"""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...
355
1
"""simple docstring""" import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class snake_case ( _UpperCamelCase , unittest.TestCase): __UpperCamelCase ...
621
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFe...
621
1
'''simple docstring''' 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 a...
109
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils...
109
1
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 10_00 ): """simple docstring""" _a , _a = 1, 1 _a = 2 while True: _a = 0 _a = fa + fa _a , _a = fa, f index += 1 ...
701
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A_ ( _lowerCAmelCase : Dict ): """simple docstring""" if "img_encoder.pos_embed" in name: _a ...
285
0
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int = 1000 ) -> int: lowercase : Optional[Any] =2**power lowercase : Dict =0 while n: lowercase , lowercase : Optional[Any] =r + n % 10, n // 10 return r ...
92
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def A__ ( __lowerCAmelCase : str , __lowerCAmelCase : str = "cpu" , __lowerCAmelCase : Union[str, None] = None ): lowerCamelCase__ = torch.load(__lowerCAme...
50
0
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, ...
151
from itertools import product def UpperCamelCase_ ( __a , __a ) -> list[int]: a__ : Union[str, Any] = sides_number a__ : Optional[int] = max_face_number * dice_number a__ : Any = [0] * (max_total + 1) a__ : Optional[Any...
151
1
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings SCREAMING_SNAKE_CASE_ = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to con...
523
'''simple docstring''' def UpperCamelCase__ ( _lowercase : List[Any] ) -> Dict: return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], ...
523
1
# 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 ...
713
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def SCREAMING_SNAKE_CASE( __UpperCamelCase ) -> int: a__ : List[Any] = prime_factors(__UpperCamelCase ) if is_square_free(__UpperCamelCase ): return -1 if len(__UpperCamelCa...
207
0
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation impo...
54
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig __lowercase = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''', '''albert-large-v1...
370
0
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_E...
657
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if _...
657
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_...
167
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts...
513
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__lowercase) class lowerCamelCase__ ( __lowercase): '''simple docstring''' _A = field(default='summar...
701
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import D...
94
0
"""simple docstring""" import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRI...
76
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset from...
30
0
'''simple docstring''' import collections import importlib.util import os import re from pathlib import Path __SCREAMING_SNAKE_CASE = 'src/transformers' # Matches is_xxx_available() __SCREAMING_SNAKE_CASE = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_stru...
712
'''simple docstring''' import numpy as np def __a ( lowerCAmelCase__ : np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
340
0
"""simple docstring""" A: List[str] = 'Alexander Joslin' import operator as op from .stack import Stack def _snake_case ( UpperCamelCase : Union[str, Any] ): UpperCAmelCase : Dict = {'''*''': op.mul, '''/''': op.truediv, '''+''': op.add, '''-''': op.sub} UpperCAmelCas...
160
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase : Any ={ 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Llama...
696
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
548
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_t...
548
1
'''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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, Ima...
467
'''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 from ..table ...
467
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = """▁""" ...
488
import qiskit def lowerCamelCase__ ( lowercase , lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : List[str] = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register SCREAMING_SNAKE_CASE : Dict ...
488
1
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE = 1000 ) ->int: """simple docstring""" lowerCAmelCase__ :List[str] = 3 lowerCAmelCase__ :str = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: resul...
93
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Optional[int] = logging.get_logger(__name__) lowerCAmelCase: int = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class a__( lowerCamelCase__ )...
526
0
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 on import sklearn # noqa: F401 # He...
703
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, ) UpperCAmelCase = { """configuration_xlm_...
351
0
'''simple docstring''' import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _a ( __lowerCAmelCase : Optional[int] , __...
347
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
347
1
from __future__ import annotations import unittest from transformers import LEDConfig, 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 ...test_pi...
367
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_available, logging...
367
1
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified...
142
"""simple docstring""" import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __lowercase : List[str] = logging.get_logger(__name__) class lowerCAmelCase ( a ): """simple docstring""" def __init__( self , ...
142
1
def __lowerCamelCase ( snake_case__ ) -> Tuple: """simple docstring""" _SCREAMING_SNAKE_CASE = [0 for i in range(len(snake_case__ ) )] # initialize interval's left pointer and right pointer _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0...
709
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class __UpperCAmelCase (_UpperCAmelCase ):...
569
0
# Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
84
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class __A( nn.Module ): ...
219
0
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 from ...test_tokenization_com...
719
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez import B...
604
0
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common impo...
592
def lowerCamelCase__ ( snake_case_ : Dict=2_8123 ) -> Tuple: __snake_case = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_divs[k * i] += k + i __...
592
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
702
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as ...
434
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ = {'''configuration_plbart''': ['''PLBART_PRETRAINED_C...
75
import collections import os import re from pathlib import Path lowerCamelCase_ : Optional[Any] = """src/transformers""" # Matches is_xxx_available() lowerCamelCase_ : Union[str, Any] = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowerCamelCase_ : i...
548
0
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging __magic_name__ : Tuple = logging.get_logger(__name__) def lowerCAme...
608
import math def lowerCAmelCase ( snake_case__ : int )-> str: A_ = 0 A_ = 0 while num > 0: A_ = num % 8 A_ = octal + (remainder * math.floor(math.pow(10 , snake_case__ ) )) counter += 1...
608
1
def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def __a ( __lowerCAmelCase , __lowerCAmelCase )...
352
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase : List[str] = """\ """ _lowerCamelCase : Optional[int] = """ Perplexity (PPL...
352
1
class _UpperCamelCase : """simple docstring""" def __init__( self ) -> Optional[Any]: A = 0 A = 0 A = {} def _UpperCAmelCase ( self , a__ ) -> Union[str, Any]: if vertex not in self.adjacency: A ...
546
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Tuple: """simple docstring""" def wrapper(*UpperCamelCase__: Union[str, Any] ...
546
1
from itertools import product def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase ) -> list[int]: '''simple docstring''' lowerCamelCase__: Any = sides_number lowerCamelCase__: int = max_face_number * dice_number ...
306
_lowercase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _lowercase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list[int]: '''simple docstring''' ...
306
1
'''simple docstring''' from __future__ import annotations __A : Union[str, Any] = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowerCamelCase_ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , ...
187
'''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 : ...
187
1
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def snake_case ( lowerCamelCase = 8 ): '''simple docstring''' __lowercase = ascii_letters + digits + punctuation return "".join(secrets.choice(...
80
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :List[Any] = logging.get_logger(__name__) _lowerCAmelCase :Tuple = { """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.j...
251
0
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 import ...
400
from collections.abc import Callable def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> float: '''simple docstring''' SCREAMING_SNAKE_CASE__ = a SCREAMING_SNAKE_CASE__ = b if function(UpperCamelCase_ ) == 0: # one of the a ...
400
1
'''simple docstring''' from maths.prime_check import is_prime def snake_case__ ( _A: int ) -> int: '''simple docstring''' if not isinstance(__snake_case , __snake_case ): lowerCAmelCase = f"Input value of [number={number}] must be an integer" raise Typ...
370
'''simple docstring''' from collections.abc import Sequence def a_ ( __snake_case : Sequence[float] , __snake_case : float ) -> float: """simple docstring""" return sum(c * (x**i) for i, c in enumerate(__snake_case ) ) def a_ ( __snake_case : Se...
676
0
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuratio...
417
'''simple docstring''' from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Any = logging.get_logger(__name__) # TODO Update this __UpperCamelCase : int =...
417
1
'''simple docstring''' import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelC...
152
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowercase__ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise ...
581
0
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a : Tuple= logging.get_logger(__name__) _a : str= { "vocab_file": "vocab.json", "merg...
192
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): _a : List[str]= yaml.safe_load( "\\nname: \"\"\nallow_empty: false\nallow_empty_text: ...
192
1
'''simple docstring''' import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts and running tests. snake_case_ = abspath(join(dirname(dirname(dirname(__f...
507
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _UpperCamelCase : str = logging.get_logger(__name__) class _lowercase( _lowerCamelCase ): """simple docstring""" def __init__( self: List[Any...
396
0
"""simple docstring""" from functools import reduce a__ : List[str] = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """1254069874715852386305071569...
309
"""simple docstring""" import operator as op a__ : Optional[int] = """scaler.pt""" a__ : Dict = """pytorch_model""" a__ : List[Any] = """random_states""" a__ : Union[str, Any] = """optimizer""" a__ : Tuple = """scheduler""" a...
309
1
from heapq import heappop, heappush import numpy as np def __lowerCAmelCase ( A , A , A , A , ): UpperCAmelCase_ , UpperCAmelCase_ = grid.shape UpperCAmelCase_ = [-1, 1, 0, 0] UpperCAmelCase_ = [0, 0, -1, 1] if allow_diago...
162
from __future__ import annotations import pandas as pd def __lowerCAmelCase ( A , A , A ): UpperCAmelCase_ = [0] * no_of_processes UpperCAmelCase_ = [0] * no_of_processes # Copy the burst time into remaining_time[] for i in range(A ): UpperCAmelC...
162
1
'''simple docstring''' import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class lowercase (...
280
'''simple docstring''' import json import sys def a ( __a , __a ) -> str: '''simple docstring''' with open(__a , encoding='''utf-8''' ) as f: UpperCamelCase__ :List[str] = json.load(__a ) UpperCamelCase__ :int ...
280
1
'''simple docstring''' from PIL import Image def A_( A : Image , A : float): def brightness(A : int) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError('level must be between -255.0 (...
3
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : str ): """simple docstring""" __magic_name__ : str = 0 # if input_string is "aba" than new_input_string become "a|b|a" __magic_name__ : Optional[Any] = '' __magic_name__ : Optio...
561
0
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": UpperCamelCase_ = argparse.ArgumentParser( description=( """Extraction some layers of the full RobertaForMaskedLM or GPT2LMHea...
88
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( __magic_name__ : list[list[int]] ) -> bool: lowercase : str =len(__magic_name__ ) # We need to create solution object to save path. lowercase : int =[[0 f...
88
1
'''simple docstring''' def _UpperCAmelCase ( ) -> Tuple: _lowerCAmelCase : List[Any] = 0 for i in range(1 , 10_01 ): total += i**i return str(_lowerCamelCase )[-10:] if __name__ == "__main__": print(solution())
384
from __future__ import annotations import math A_ = "2020.9.26" A_ = "xcodz-dot, cclaus, dhruvmanila" def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase )-> tuple[float, float]: """simple docs...
604
0
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffus...
127
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig lowercase_: List[Any] = logging.get_logger(__name__) class lowercase__ : """simple docst...
127
1
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def A_ ( lowercase_ ) -> str: # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Uni...
326
lowerCAmelCase_ = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 1_0: "a", 1_1: "b", 1_2: "c", 1_3: "d", 1_4: "e", 1_5: "f", } def A_ ( lowercase_ ) -> str: assert type(lowercase_ ) in...
326
1
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class __lowercase ( lowerCamelCase__ ): __UpperCAmelCase = CustomTokenizer pass
676
def A ( snake_case__ : int ) -> bool: '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): __snake_case = f"Input value of [number={number}] must be an integer" raise TypeError(snake_case__ ) if number < 0: return Fal...
676
1
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 UpperCamelCase_ : Optional[int] = logging.get_logger(__name__) UpperC...
461
from __future__ import annotations def UpperCamelCase ( _UpperCAmelCase : str , _UpperCAmelCase : list[str] | None = None ) -> list[list[str]]: '''simple docstring''' _lowercase : Dict = word_bank or [] # create a table _lowercase : int...
461
1
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging __lowerCamelCase = '''\ ''' __lowerCamelCase = ''' Perplexity (PPL) is one of the most common metrics for evaluat...
708
import operator def _snake_case ( __snake_case , __snake_case = False , __snake_case = None ) -> list: '''simple docstring''' UpperCAmelCase_ : Optional[int] = operator.lt if reverse else operator.gt UpperCAmelCase_ : int = so...
455
0
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> int: """simple docstring""" if not isinstance(lowercase_ , lowercase_ ): raise TypeError('''Input value must be an \'int\' type''' ) A__ = 0 while number: position += 1 ...
87
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTeste...
221
0
"""simple docstring""" import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStruct...
716
"""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 _UpperCAmelCase = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP"""...
36
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__a ) class _SCREAMING_SNAKE_CASE ( __a ): __SCREAMING_SNAKE_CASE :str ...
432
'''simple docstring''' import colorsys from PIL import Image # type: ignore def UpperCamelCase ( a , a , a ) -> float: '''simple docstring''' __magic_name__ = x __magic_name__ = y for step in range(a ): # noqa: B007 __ma...
432
1
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def lowerCamelCase_(__SCREAMING_SNAKE_CASE = 1_000_000 , __SCREAMING_SNAKE_CASE = 10 )-> str: _SCREAMING_SNAKE_CASE : defaultdict = defaultdict(__lowercase ) for outer_width in range(3...
704
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase_ = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSp...
635
0
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class lowerCAmelCase_ ( unittest.TestCa...
395
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow snake_case__ = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.') @require_t...
395
1
"""simple docstring""" def _snake_case ( UpperCamelCase : int = 1000 ): UpperCAmelCase : Optional[int] = 2**power UpperCAmelCase : Optional[Any] = str(UpperCamelCase ) UpperCAmelCase : Union[str, Any] = list(UpperCamelCase ) UpperCAmelCase : Dict = 0 for i ...
359
"""simple docstring""" import requests from bsa import BeautifulSoup def _snake_case ( UpperCamelCase : str = "AAPL" ): UpperCAmelCase : Any = F"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}" UpperCAmelCase : Optional[int] = BeautifulSoup(requests.get(UpperCamelCase ).text ...
359
1
# 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...
485
import argparse import collections import os import re 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_table.py SCREAMING_SNAKE_CASE = 'src/transfo...
485
1
import math def __lowerCAmelCase ( __snake_case ): __lowerCAmelCase = 0 __lowerCAmelCase = 0 while num > 0: __lowerCAmelCase = num % 8 __lowerCAmelCase = octal + (remainder * math.floor(math.pow(10 , __s...
290
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : Tuple = { '''caidas/swin2sr-classicalsr-x2-64''': ( '''https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/m...
290
1
def A ( ) -> Optional[Any]: UpperCamelCase__ :int = 0 for i in range(1 , 1001 ): total += i**i return str(lowercase__ )[-10:] if __name__ == "__main__": print(solution())
45
'''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...
90
0
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient _lowerCAmelCase : int = WebClient(token=os.environ['''CI_SLACK_BOT_TOKEN''']) def lowerCamelCase_( _lower...
719
"""simple docstring""" import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common...
386
0
'''simple docstring''' import os def _UpperCamelCase ( ) -> Union[str, Any]: with open(os.path.dirname(__UpperCamelCase ) + '/grid.txt' ) as f: lowerCamelCase_ = [] # noqa: E741 for _ in range(20 ): l.append([int(__UpperCamelCase ) for x in f.r...
42
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 TFCamembertModel @r...
333
0
'''simple docstring''' import inspect import re 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 lowerCAmelCase : Union[str,...
630
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Any = { """configuration_x_clip""": [ """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XCLIPConfi...
630
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
47
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 from transformers.configuration_...
298
0
'''simple docstring''' 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__ :...
496
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase__ : Optional[Any] ...
496
1
import argparse from collections import defaultdict def lowerCAmelCase_ ( __a , __a , __a , __a , __a ) -> Optional[int]: """simple docstring""" lowerCamelCase__: str =F"""{file}_{class_name}_{test_name}""" done_test[_id] ...
59
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer snake_case_ : Tuple = loggin...
212
0
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class SCREAMING_SNAKE_CASE_ ( _a ): """simple docstring""" def UpperCamelCase__ ( self :Any, snake_case :str): """simple docstring""" ...
557
from math import isqrt, loga def _snake_case (_snake_case : int) -> list[int]: _lowercase =[True] * max_number for i in range(2 , isqrt(max_number - 1) + 1): if is_prime[i]: for j in range(i**2 , _snake_case , _snake_case): ...
557
1
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def A__ ( self ) -> Any: __lowerCAmelCase = [ ...
465
import math import sys def lowerCamelCase_ ( lowerCAmelCase__ : str ) -> str: '''simple docstring''' A = '' try: with open(lowerCAmelCase__ , 'rb' ) as binary_file: A = binary_file.read() ...
106
0
'''simple docstring''' import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def UpperCamelCase ( lowercase_ = 3 ) -> str: '''simple docstring''' if isinstance(lowerCAmelCase__ , lowerCAmelCas...
714
import argparse import os import re lowerCamelCase__ : List[Any] = """src/transformers""" # Pattern that looks at the indentation in a line. lowerCamelCase__ : Union[str, Any] = re.compile(R"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. lowerCamel...
495
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Tuple ={ """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimeSeriesTransform...
54
from __future__ import annotations def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' if b == 0: return (1, 0) ((UpperCAmelCase_) , (UpperCAmelCase_)) =extended_euclid(lowercase__ , a % b ) UpperCAmelC...
54
1
'''simple docstring''' def __A ( _SCREAMING_SNAKE_CASE : Dict ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[Any] = 0 __SCREAMING_SNAKE_CASE : Tuple = len(_SCREAMING_SNAKE_CASE ) ...
564
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base impo...
564
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCamelCase__ ) class SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ): """simple docstring""" lower...
327
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.sched...
327
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowerCAmelCase = logging.get_logger(__name__) class lowerCamelCase ( _A ): def __init__( self , *a_ , **a_ ): warnings.w...
551
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlo...
551
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class SCREAMING_SNAKE_CASE ( snake_case_ ): def __init__( self : Optional[Any] ): '''simple docstring''' self.test() ...
442
'''simple docstring''' 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 transform...
442
1
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nice mi...
390
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class SCREAMING_SNAKE_CASE__ ( __UpperCamelCase ): def __lt__( self : Tuple , _lowerCAmelCase : Optional[int] ): ret...
390
1