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
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( AutoConfig, ...
652
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 a =logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' ...
652
1
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 A_ ( snake_case : Tuple , snake_case : List[str] , snake_case ...
451
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaForSe...
451
1
'''simple docstring''' import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1_3_3_7 , num_examples=4_2 , ...
378
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_p...
225
0
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi...
719
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__ = """src/transformers""" # This is to make sure the transforme...
626
0
def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> str: if not (isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )): raise ValueError('longest_common_substri...
235
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = {"""vocab...
235
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_UpperCamelCase ): """simple docstring""" a_ = ["""onnx"""] def __init__( self : int , *lowerCAmelCase_ : Optional[Any] , ...
709
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _snake_case : Optional[int] = logging.get_logger(__name__) _snake_case : List[...
421
0
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets A : List[Any] = '\\n@inproceedings{snover-etal-2006-study,\n title = "A Study of Translation Edit Rate with Targeted Human Annotation",\n author = "Snover, Matthew and\n Dorr, Bonnie and\n ...
219
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, requ...
219
1
"""simple docstring""" 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 _a ...
711
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowercase ( _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' def is_in_circle(_SCREAMING_SNAKE_...
95
0
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging...
38
import math from datetime import datetime, timedelta def UpperCAmelCase__ ( lowerCamelCase_ : int ): __a : Union[str, Any] = year % 1_9 __a : int = year % 4 __a : Optional[int] = year % 7 __a : Dict...
47
0
from ..utils import DummyObject, requires_backends class _UpperCamelCase( metaclass=SCREAMING_SNAKE_CASE ): __A: Dict = ["""keras_nlp"""] def __init__( self : List[str] , *_lowerCamelCase : Optional[Any] , **_lowerCamelCase : Optional[Any] ): requi...
328
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { 'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/config.json', 'funnel-transformer/small-base': 'h...
328
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusToken...
334
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 A ( Uppe...
15
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ : List[Any] = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """B...
720
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_fu...
317
0
from __future__ import annotations from PIL import Image # Define glider example UpperCAmelCase__ : List[Any] = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0...
313
'''simple docstring''' from __future__ import annotations def a ( UpperCamelCase_ : str , UpperCamelCase_ : list[str] | None = None , UpperCamelCase_ : dict[str, float] | None = None , UpperCamelCase_ : bool = False , ) -> tuple[int, ...
538
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
407
from functools import lru_cache @lru_cache def _lowerCAmelCase ( __magic_name__ :int ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doc...
407
1
'''simple docstring''' import json import sys def lowerCamelCase ( UpperCAmelCase__ : Tuple , UpperCAmelCase__ : int ) -> Tuple: '''simple docstring''' with open(UpperCAmelCase__ , encoding='utf-8' ) as f: SCREAMING_SNAKE_CASE__ :Op...
209
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : str , UpperCAmelCase__ : int ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE__ :list[list[str]] = [[] for _ in range(UpperCAmelCase__ )] SCREAMING_SNAKE_CASE__ :Any ...
209
1
def a_ ( __snake_case ) -> None: '''simple docstring''' UpperCamelCase_ = generate_pascal_triangle(__snake_case ) for row_idx in range(__snake_case ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ' ) ...
712
import argparse import hashlib # hashlib is only used inside the Test class import struct class A : def __init__( self : Optional[int] , __UpperCAmelCase : str ) -> Dict: """simple docstring""" UpperCam...
559
0
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": _lowercase : Dict = pd.read_csv('sample_data.c...
49
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if not is_vision_available(): ...
593
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class a ( __lowerCAm...
83
import colorsys from PIL import Image # type: ignore def snake_case ( snake_case__ :float , snake_case__ :float , snake_case__ :int) -> float: _A = x _A = y for step in range(snake_case__): # noqa: B007 _A ...
83
1
"""simple docstring""" import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore A_ : Optional[Any] = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" A_ : List[Any]...
265
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ : Optional[int] = { 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_A...
265
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __lowerCamelCase = logging.get_logger(__name__) ...
700
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common impor...
328
0
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
267
'''simple docstring''' from sklearn.metrics import mean_squared_error import datasets SCREAMING_SNAKE_CASE__ = "\\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 Thi...
267
1
from __future__ import annotations from math import pi, sqrt def snake_case_ ( snake_case , snake_case ) -> tuple: if inductance <= 0: raise ValueError('Inductance cannot be 0 or negative' ) elif capacitance <= 0: raise...
335
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONA...
335
1
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ (metaclass=__snake_case ): __lowerCamelCase : Optional[Any] = ["""flax""", """transformers"""] def __init__( self , *a , **a): requires_backends(self , ['flax', 'transformers']) @classme...
164
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class SCREAMING_SNAKE_...
164
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen...
486
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : List[Any] = {"""configuration_sew""": ["""SEW_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SEWConfig"""]} try: if not is_torch_available(): raise ...
486
1
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = {'vocab_file': 'sentencepi...
61
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A ( unittest.TestCase ): '''simple docstring''' ...
15
0
"""simple docstring""" from manim import * class __a (UpperCamelCase_): '''simple docstring''' def _a ( self ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE__ : Any = Rectangle(height=0.5 , width=0.5 ) SCREA...
12
"""simple docstring""" 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 T...
12
1
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCAmelCase_ ( _lowerCamelCase: List[str] , _lowerCamelCase: List[str] , _lowerCamelCase: str = None ): if version.parse(hfh.__version__...
578
"""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/LI...
673
0
'''simple docstring''' import math from collections.abc import Callable def __magic_name__( _A , _A , _A ): '''simple docstring''' UpperCamelCase__ = xa UpperCamelCase__ = xa while True: if x_n == x_na or function(snake_ca...
706
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): '''simpl...
265
0
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageP...
570
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
0
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration _lowercase : int = HfArgumentParser(InitializationArguments) _lowercase : Optional[int] = parser.parse_args() # Load codeparrot tokenizer ...
546
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _UpperCamelCase : """simple docstring""" @property def _U...
546
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_...
102
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A__ = logging.get_logger(__name__) A__ = """▁""" A__ = {"""vocab_f...
166
0
'''simple docstring''' class lowerCAmelCase_: '''simple docstring''' def __init__( self ,__UpperCAmelCase ,__UpperCAmelCase ,__UpperCAmelCase ) -> Any: lowerCAmelCase__ : Tuple = name lowerCAmelCase__ : Optional[Any] = va...
160
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowerCAmelCase = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokeniz...
160
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowercase__ :Tuple = TypeVar('T') class snake_case ( Generic[T] ): '''simple docstring''' def __ini...
522
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowercase__ :Tuple = TypeVar('T') class snake_case ( Generic[T] ): '''simple docstring''' def __ini...
522
1
lowerCAmelCase = 256 # Modulus to hash a string lowerCAmelCase = 1_000_003 def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> bool: '''simple docstring''' __UpperCAmelCase : List[str] = len(lowercase_ ) __Up...
713
from string import ascii_uppercase lowerCAmelCase = {char: i for i, char in enumerate(ascii_uppercase)} lowerCAmelCase = dict(enumerate(ascii_uppercase)) def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' ...
675
0
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_m...
512
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=UpperCAmelCase__ ): '''simple docstring''' __UpperCamelCase = ["torch", "torchsde"] def __init__( self : Dict , *lowercase_ : ...
512
1
'''simple docstring''' import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A ( _a ,unittest.TestCase ): lowercase_ = ...
377
'''simple docstring''' def snake_case_ (UpperCamelCase : int ): '''simple docstring''' if n == 1 or not isinstance(UpperCamelCase , UpperCamelCase ): return 0 elif n == 2: return 1 else: _a = ...
377
1
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def a (lowerCAmelCase__ = True , *lowerCAmelCase__ , **lowerCAmelCase__ ): if not is_tqdm_available(): raise ImportError("""Accelerate's `...
99
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
1
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils imp...
700
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipelin...
168
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" _SCREAMING_SNAKE_CASE = 2 _SCREAMING_SNAKE_CASE = [] while i * i <= n: if n % i: i += 1 else: n //= i ...
605
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_filename, ...
605
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def __snake_case ( lowercase : Callable[[int | float], int | float] , lowercase : int | float , lowercase : int | float , lowercase : int = 100 , ): ...
420
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ = { '''configuration_graphormer''': ['''GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GraphormerConfig'''], } ...
420
1
from pathlib import Path import numpy as np from PIL import Image def _lowerCamelCase ( SCREAMING_SNAKE_CASE_ : np.ndarray ): """simple docstring""" a_ , a_ , a_ : Optional[Any] = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2_989 *...
419
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Union[str, Any] = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } ...
419
1
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase : List[Any] = logging.get_logger(__name__) Upp...
610
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer UpperCamelCase : List[Any] = loggi...
610
1
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
def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase, __UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ =len(__UpperCamelCase ), len(grid[0] ) if ( min(__UpperCamelCase, __UpperCamelCase ...
151
1
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if ve...
623
"""simple docstring""" from __future__ import annotations from typing import Any def lowerCAmelCase_( lowercase_ : list[Any] ) -> None: create_state_space_tree(lowercase_ , [] , 0 ) def lowerCAmelCase_( lowercase_ : list[Any] , ...
623
1
import math import random from typing import Any from .hill_climbing import SearchProblem def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE = True ,_SCREAMING_SNAKE_CASE = math.inf ,_SCREAMING_SNAKE_CASE = -math.inf ,_SCREAMING_SNAKE_CASE = math.inf ,_SCREAMING_SNAKE_CASE = -ma...
311
import math import os import sys def __lowercase ( lowerCamelCase : str ): UpperCamelCase_ : Dict = '' try: with open(lowerCamelCase , 'rb' ) as binary_file: UpperCamelCase_ : Union[str, Any] = binary_file.read() for dat in data: UpperCamelCase_ : Optional[int]...
417
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : int = logging.get_logger(__name__) __a : int = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json''', } ...
706
import unittest from knapsack import knapsack as k class UpperCAmelCase( unittest.TestCase ): """simple docstring""" def __a ( self ) -> Union[str, Any]: """simple docstring""" lowercase__ : Optional[Any] ...
298
0
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, l...
696
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
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.convert_swit...
421
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.configuration_bert import BertConfig from...
421
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils impo...
30
'''simple docstring''' def lowercase_ ( _lowercase , _lowercase , _lowercase , _lowercase ) -> bool: '''simple docstring''' if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vertex is not already in path ret...
422
0
from collections import deque def _lowerCamelCase( UpperCamelCase__ : Tuple ) -> Any: A : int = len(lowerCamelCase_ ) A : Dict = deque() A : Optional[int] = [False for _ in range(lowerCamelCase_ )] A : ...
712
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # a...
537
0
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": lowerCAmelCase_ = pd.read_csv("sample_data.csv", header=None) lowerCAmelCase_ = df.shape[:1][...
326
from math import pi, sqrt def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: float ) -> float: if num <= 0: raise ValueError("math domain error" ) if num > 171.5: raise OverflowError("math range error" ) elif num - int(lowerCAmelCase ) not in (0, 0.5): raise Not...
300
0
"""simple docstring""" import os from pathlib import Path def __a ( A , A , A ): '''simple docstring''' lowercase__ = { "en": "Machine learning is great, isn\'t it?", "ru": "Машинное обучение - это здорово, не так ли?", "de": "Mas...
714
"""simple docstring""" import os import sys lowerCAmelCase_: Any = os.path.join(os.path.dirname(__file__), "src") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSeq...
668
0
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttentio...
626
"""simple docstring""" def _lowerCamelCase ( __a ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = 1 while repunit: SCREAMING_SNAKE_CASE_ = (10 * repunit + 1) % divisor repunit_index += 1 return repuni...
626
1
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, TrainingArguments,...
202
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase__ = get_tests_dir("fixtures/test_sent...
202
1
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def SCREAMING_SNAKE_CASE__ ( snake_case__ :Tuple ) -> Tuple: # This defines a "chinese character" as anything in the CJK Unicode block: ...
67
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
636
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer a_ : int = lo...
714
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTes...
445
0
'''simple docstring''' def A (__lowerCamelCase :int , __lowerCamelCase :int ): if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _lowerCAmelCase = str(bin(__lowerCamelCase ) )[2:] # remove the leading "0b" _low...
5
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : List[str] = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], 'configuration_data2vec_t...
479
0
"""simple docstring""" from __future__ import annotations def lowercase_ ( _lowercase : list[int] , _lowercase : int ): '''simple docstring''' if len(_lowercase ) < k or k < 0: raise ValueError("Invalid Input" ) UpperCAmelCase : List[str] ...
292
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allo...
292
1
'''simple docstring''' import random from typing import Any def UpperCAmelCase ( UpperCAmelCase__ : list): for _ in range(len(UpperCAmelCase__)): lowerCamelCase : List[Any] = random.randint(0 , len(UpperCAmelCase__) - 1) lowerCam...
320
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { 'configuration_mctct': ['MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MCTCTConfig'], 'feature_extraction_mctct': ['MCTCTFeatureExtracto...
320
1
'''simple docstring''' def lowerCamelCase ( lowerCamelCase : int): if not isinstance(lowerCamelCase , lowerCamelCase): A_ : List[Any] = F'Input value of [number={number}] must be an integer' raise TypeError(lowerCamelCase) if nu...
27
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedToke...
27
1
'''simple docstring''' 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_roberta import...
48
'''simple docstring''' import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ : List[Any] = logging.get_logger(__name__) UpperCAmelCase__ : List[str] = {"vocab_file": "vocab.json"} Uppe...
48
1
"""simple docstring""" import os import string import sys lowerCamelCase : Any = 1 << 8 lowerCamelCase : Optional[int] = { """tab""": ord("""\t"""), """newline""": ord("""\r"""), """esc""": 2_7, """up""": 6_5 + ARROW_KEY_FLAG, """...
168
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but ...
168
1
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
235
from __future__ import annotations def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> int: if len(_SCREAMING_SNAKE_CASE ) < k or k < 0: raise ValueError('Invalid Input' ) lowercase__ = lowercase__ = sum(a...
235
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 a_ = logging.get_logger(__name__) a_ = { """google/mobilen...
717
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_...
349
0
'''simple docstring''' import argparse import os import re import packaging.version __UpperCAmelCase ="examples/" __UpperCAmelCase ={ "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__version__\s+=\s+\"([^...
546
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _lowerCAmelCase = logging.get_logger(__name__) def lowercase ( _a=None ,_a=None ) -> List[Any]: return field...
137
0
'''simple docstring''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamelCase_ = (CMStochasticIterativeScheduler,) lowerCamelCase_ ...
713
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'google/pix2struct-textcaps-base': ( 'https://huggingface.co/google/pix2struct-textcaps...
59
0
from __future__ import annotations from random import random from typing import Generic, TypeVar a_ = TypeVar("""KT""") a_ = TypeVar("""VT""") class UpperCAmelCase__ ( Generic[KT, VT] ): """simple docstring""" def __init__( self: Optional[Any] , __l...
221
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a_ = logging.get_logger(__name__) a_ = {"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""",...
221
1
"""simple docstring""" import os import platform import sys lowerCAmelCase_ : List[str] = '''3''' print('''Python version:''', sys.version) print('''OS platform:''', platform.platform()) print('''OS architecture:''', platform.machine()) try: import torch print('''Torch version:''', t...
719
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = 0 UpperCAmelCase = len(lowerCAmelCase ) for i in range(n - 1 ): for j in range(i + 1 , lowerCAmelCase ): ...
378
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ : Any = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_available(): raise OptionalDependencyN...
488
'''simple docstring''' import math def snake_case_ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): '''simple docstring''' return math.pow(SCREAMING_SNAKE_CASE__ , 2 ) - a def snake_case_ ( SCREAMING_SNAKE_CASE__ ): '''s...
672
0
'''simple docstring''' from pathlib import Path import json import tempfile from transformers import FSMTTokenizer, FSMTConfig, FSMTForConditionalGeneration from transformers.models.fsmt.tokenization_fsmt import VOCAB_FILES_NAMES _A : Any ='''tiny-wmt19-en-ru''' # Build # borrowed from a test _...
717
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Optional[Any] ={'''configuration_xlnet''': ['''XLNE...
4
0
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple reposito...
431
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _A = collections.namedtuple('''_Datasets''', ['''train''', '''validation'...
431
1
import functools from typing import Any def _UpperCamelCase (a__ :str , a__ :list[str] ): """simple docstring""" if not isinstance(a__ , a__ ) or len(a__ ) == 0: raise ValueError("""the string should be not empty string""" ) ...
548
from typing import Any def _UpperCamelCase (a__ :list ): """simple docstring""" if not input_list: return [] UpperCamelCase__ = [input_list.count(a__ ) for value in input_list] UpperCamelCase__ = max(a__ ) #...
548
1
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging __UpperCAmelCase = logging.get_logger(__name__) class lowerCamelCase (a_ ): ...
406
"""simple docstring""" import socket def _lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase = socket.gethostname() UpperCAmelCase ...
673
0
"""simple docstring""" from graphs.minimum_spanning_tree_kruskal import kruskal def _lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase = 9 UpperCAmelCase = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], ...
378
"""simple docstring""" from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ...
378
1
from typing import TYPE_CHECKING from ...utils import _LazyModule __lowerCamelCase : str = {"""tokenization_byt5""": ["""ByT5Tokenizer"""]} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys __lowerCamelCase : List[str] = _LazyModule(__name__, glo...
629
import os def A_ ( ) -> Union[str, Any]: with open(os.path.dirname(_lowerCAmelCase ) + "/grid.txt" ) as f: UpperCamelCase : Optional[Any] = [] # noqa: E741 for _ in range(20 ): l.append([int(_lowerCAmelCase ) for x in f.readline().split()] ) UpperCamelCase : ...
629
1
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 __lowerCamelCase : Dict = logging.getLogger() @unittest.skip('Temporarily disable the doc test...
701
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCamelCase : Union[str, Any] = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""",...
38
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', # See all Cvt models at https://h...
60
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowercase_ : """simple docstring""" ...
483
0
"""simple docstring""" from __future__ import annotations def lowerCAmelCase (__UpperCamelCase : list , __UpperCamelCase : int | None = None , __UpperCamelCase : int | None = None ): """simple docstring""" if start is None: ...
296
"""simple docstring""" import qiskit def lowerCAmelCase (__UpperCamelCase : int , __UpperCamelCase : int ): """simple docstring""" __UpperCamelCase =qiskit.Aer.get_backend('''aer_simulator''' ) __UpperCamelCase =qiskit.QuantumCircuit(4 ...
296
1
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() cl...
465
"""simple docstring""" def __magic_name__ ( UpperCamelCase : int , UpperCamelCase : list[int] , UpperCamelCase : int ) -> int: def count_of_possible_combinations(UpperCamelCase : int ) -> int: if target < 0: return 0 if ta...
273
0
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __lowerCamelCase :str = collections.namedtuple('_...
721
"""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_identifie...
42
0
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute_m...
55
from __future__ import annotations import math def lowercase ( a , a ): '''simple docstring''' SCREAMING_SNAKE_CASE_ :List[Any] = u for i in range(1 , a ): SCREAMING_SNAKE_CASE_ :Union[str, Any] = temp * (u - i) return temp def lowercase ( ...
631
0
from __future__ import annotations _A = 10 def __SCREAMING_SNAKE_CASE ( UpperCamelCase : list[int] ) -> list[int]: """simple docstring""" a_ = 1 a_ = max(UpperCamelCase ) while placement <= max_digit: # declare and initialize empty buckets a_ = ...
403
import math _A = 10 _A = 7 _A = BALLS_PER_COLOUR * NUM_COLOURS def __SCREAMING_SNAKE_CASE ( UpperCamelCase : int = 20 ) -> str: """simple docstring""" a_ = math.comb(UpperCamelCase , UpperCamelCase ) a_ = math.comb(NUM_BALLS ...
403
1
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=1024 ) -> Union[str, Any]: lowerCamelCase__ , lowerCame...
295
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_...
295
1
import os def lowercase_ ( lowercase__ ) ->Dict: _snake_case: List[str] = len(grid[0] ) _snake_case: Any = len(lowercase__ ) _snake_case: Optional[Any] = 0 _snake_case: List[Any] = 0 _snake_case: Tuple = ...
702
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_visi...
273
0
'''simple docstring''' 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 .toke...
679
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger __UpperCamelCase : Optional[Any] = '<<<<<<< This should probably be modified because it mentions: ' __UpperCamel...
248
0
'''simple docstring''' import math from collections.abc import Callable def __UpperCAmelCase ( SCREAMING_SNAKE_CASE__: Callable[[float], float], SCREAMING_SNAKE_CASE__: float, SCREAMING_SNAKE_CASE__: float ) -> float: """simple docstring""" __a = xa ...
270
'''simple docstring''' import warnings from .generation import TFGenerationMixin class __SCREAMING_SNAKE_CASE ( _lowerCAmelCase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py...
270
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamelCase_ = ["image_processor", "tokenizer"] lowerCamelCase_ = "CLIPImageProcessor"...
6
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __lowerCamelCase : """simple docstring""" a = 42 a = None a = None A : Optional[Any] = na...
128
0
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import A...
2
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging __SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : str = { 'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/resolv...
2
1
_UpperCAmelCase : Any = 6_5521 def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = 1 snake_case_ = 0 for plain_chr in plain_text: snake_case_ = (a + or...
362
import argparse import struct import unittest class lowercase : def __init__( self , snake_case ): snake_case_ = data # Initialize hash values snake_case_ = [ 0x6A09E667, 0xBB67AE85, ...
362
1
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.p...
715
"""simple docstring""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from...
93
0
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 __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''facebook/data2vec-...
40
from __future__ import annotations _lowerCAmelCase : 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 : '''simple docs...
246
0
from __future__ import annotations from collections import namedtuple def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__): lowerCAmelCase_ : Optional[int] = namedtuple("result" , "name value") if (voltage, current, power).count(0) != 1: raise Va...
683
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowercase = Lock() def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__): ...
683
1
'''simple docstring''' def a ( _UpperCAmelCase , _UpperCAmelCase ) -> list: """simple docstring""" a_ = len(_UpperCAmelCase ) a_ = [] for i in range(len(_UpperCAmelCase ) - pat_len + 1 ): a_ = True for j in range(_...
697
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _snake_case ( unittest.TestCase ): """simple docstring""" def __SCREAMING_SNAKE_CASE ( self ) ->...
697
1
import math import random def a__ ( A_, A_ = False ): '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value __lowerCAmelCase : str = 0.02 def a__ ( A_, A_ ): '...
714
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Tuple = logging.get_logger(__name__) __lowerCAmelCase : Tuple = { 'SCUT-DLVCLab/lilt-roberta-en-base': ( 'https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolv...
76
0
from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=A__ ): """simple docstring""" a = ["torch", "torchsde"] def __init__( self : str , *__lowerCamelCase : int , **__lowerCamelCase : Dict ) -> List[Any...
493
import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
493
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 _lowercase = logging.get_logger(__name__) _lowercase = { ...
704
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration _lowercase = { '''tiny.en''': '''https://openaipublic.azureedge.net/main/whisper/models/d3dd5...
96
0
# 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 ap...
80
def a(lowercase__ ): '''simple docstring''' snake_case_ = len(lowercase__ ) for _ in range(lowercase__ ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: snake_case_ , snake_case_ = arr[i + 1], arr[i] return arr if __name__ =...
187
0
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging __SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) def snake_case_ ( lowercase__ : Union[tf.Tensor, np.ndarray] ): '''simple docstr...
149
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_modeling_flax_common import FlaxMo...
149
1
import collections import os import re from pathlib import Path snake_case__ : Any = '''src/transformers''' # Matches is_xxx_available() snake_case__ : Optional[Any] = re.compile(R'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} sna...
392
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokeni...
392
1
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( """files""" , [ ["""full:README.md""", """dataset_infos.json"""], ["""empty:README.m...
716
"""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_channe...
48
0