code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __A : Optional[Any] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst ...
334
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ( lowercase__ ): ...
334
1
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common impo...
138
def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : dict ): UpperCamelCase_ : str = set() # edges = list of graph's edges UpperCamelCase_ : Any = get_edges(_SCREAMING_SNAKE_CASE ) # While there are still elements in edges list, take an arbitrary edge ...
138
1
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ) -> Optional[Any]: """simple docstring""" if index == r: for j in range...
77
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def __UpperCamelCase ( A ): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.config , args....
415
0
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') UpperCAmelCase_ = """https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) UpperCAmelCase_ = ...
720
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCAmelCase_ = logging.get_logger(__name__) class lowerCamelCase__( __lowerCamelCase , __lowerCa...
80
0
# Function to print upper half of diamond (pyramid) def __snake_case ( lowerCAmelCase_ ) -> List[Any]: for i in range(0 , lowerCAmelCase_ ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end='''''' ) for _ in range(0 ...
100
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
100
1
'''simple docstring''' from functools import reduce a = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489...
718
'''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 if is_torch_available(): import...
13
0
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=A ): '''simple docstring''' a_ : Tuple = ["flax"] def __init__( self : Any , *_lowerCamelCase : Dict , **_lowerCamelCase : Tuple ): ...
519
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency __UpperCamelCase : Tuple = { 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, 'C':...
519
1
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowercase_ ( __snake_case : List[Any] ) -> List[Any]: '''simple do...
703
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __UpperCAmelCase ...
57
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "feature_extraction_encodec...
619
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( _a ): snake_case : Optional[Any] = """encoder-decoder""" snake_case : Optio...
619
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Optional[int] = { 'configuration_xlm_roberta_xl': [ 'XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMRobertaXLConfig', 'XLMRobertaX...
484
# 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 requi...
484
1
'''simple docstring''' import string from math import logaa def __UpperCamelCase ( lowercase__ : str, lowercase__ : str ): '''simple docstring''' __lowercase =document.translate( str.maketrans('', '', string.punctuation ) ).replace('\n'...
119
'''simple docstring''' def __UpperCamelCase ( lowercase__ : int ): '''simple docstring''' if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) __lowercase =[0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 __...
119
1
"""simple docstring""" def lowercase_ ( _lowerCamelCase: Tuple ) -> str: '''simple docstring''' if collection == []: return [] # get some information about the collection __lowerCamelCase : Dict = len(_lowerCamelCase ) __lower...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { '''configuration_bert''': ['''B...
366
0
'''simple docstring''' import math def _UpperCamelCase ( lowerCAmelCase__: list ,lowerCAmelCase__: int = 0 ,lowerCAmelCase__: int = 0 ) -> list: SCREAMING_SNAKE_CASE_ = end or len(lowerCAmelCase__ ) for i in range(lowerCAmelCase__ ,lowerCAmelCase...
294
'''simple docstring''' def _UpperCamelCase ( lowerCAmelCase__: int = 1000 ) -> int: SCREAMING_SNAKE_CASE_ = 2**power SCREAMING_SNAKE_CASE_ = str(lowerCAmelCase__ ) SCREAMING_SNAKE_CASE_ = list(lowerCAmelCase__ ) SCREAMING_SNAKE_CASE_ ...
294
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from ....
278
def A ( UpperCAmelCase ): if n == 1 or not isinstance(UpperCAmelCase , UpperCAmelCase ): return 0 elif n == 2: return 1 else: _snake_case : List[Any] = [0, 1] for i in range(2 , n + 1 ): ...
278
1
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 __A = logging.get_logger(__name__) __A = ...
484
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __A = logging.get_logge...
484
1
def _UpperCAmelCase ( a : list[int] ): if not numbers: return 0 if not isinstance(a , (list, tuple) ) or not all( isinstance(a , a ) for number in numbers ): raise ValueError("""numbers must be an iterable of integers""" ) snake_case_...
99
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() class _lowerCAmelCase ( l...
99
1
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
91
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase , unittest....
721
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( '''kwargs, expected''' , [ ({'''num_shards''': 0, '''max_num_jobs''': 1}, []), ({'''num_shards''': 10, '''max_num_jobs''...
388
0
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class __magic_name__ : lowercase : Optional[Union[str, Path]] =None lowercase : bool =False lowercase : bool =False lowercase : ...
323
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppTokeniz...
323
1
from decimal import Decimal, getcontext from math import ceil, factorial def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> str: if not isinstance(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ): raise TypeError("Undefined for non-integers" ) el...
298
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
298
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, ...
68
def a__ ( lowercase__ , lowercase__ , lowercase__ ): '''simple docstring''' if len(lowercase__ ) != len(lowercase__ ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight mu...
54
0
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobert...
703
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils...
266
0
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup A : int = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2col_cuda.cuh',...
371
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
371
1
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificati...
714
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord import VideoReader if i...
462
0
'''simple docstring''' from typing import Any def _lowerCAmelCase ( lowercase : Optional[Any] ) ->list[Any]: """simple docstring""" if not input_list: return [] lowercase__ = [input_list.count(_lowerCAmelCase ) for value i...
161
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 import PaddingStrategy, logging __lo...
629
0
def A__ ( __A , __A , __A , __A , __A ): '''simple docstring''' if index == number_of_items: return 0 _lowerCamelCase : Optional[int] = 0 _lowerCamelCase : str = 0 _lowerCamelCase : List[Any] = knapsack(__...
15
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def A__ ( ): '''simple docstring''' _lowerCamelCase : Optional[int] = ArgumentParser( ...
15
1
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: str , UpperCamelCase__: str ): SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = [[False for _ in range(m + 1 )] for _ in...
6
"""simple docstring""" import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=loggi...
510
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class __a ( __SCREAMING_SNAKE_CASE ): def __init__( self : List[Any] ): '''simple docstring''' self.test() def UpperCAmelCase__ ( self : List[Any] ...
720
'''simple docstring''' import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder a = "__DUMMY_TRANSFORMERS_USER__" a = "Dummy User" a = "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" ...
13
0
import os def _UpperCAmelCase (UpperCamelCase_ : Any ): '''simple docstring''' _lowerCAmelCase : Any = len(grid[0] ) _lowerCAmelCase : List[Any] = len(UpperCamelCase_ ) _lowerCAmelCase : Optional[int] ...
429
# 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...
429
1
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common impo...
711
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def _a ( _SCREAMING_SNAKE_CASE = 8 ) -> str: snake_case_ = ascii_letters + digits + punctuation return "".joi...
2
0
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 C...
97
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCAmelCase ( unittest.Te...
585
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction...
222
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
222
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_...
580
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def __snake_case ( SCREAMING_SNAKE_CASE: int , SCREAMING_SNAKE_CASE: int , SCREAMING_SNAKE_CASE: int , SCREAMING_SNAKE_CASE: int , S...
580
1
'''simple docstring''' import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
704
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging a = logging.get_logger(__name__) class __a ( _snake_case ): __UpperCamelCase : int...
13
0
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from tokeni...
300
"""simple docstring""" class lowerCamelCase : '''simple docstring''' def __init__( self : str , _snake_case : list[int] ) -> None: SCREAMING_SNAKE_CASE__ = len(_snake_case ) SCREAMING_SNAKE_CASE__ = [0] * len_arr...
159
0
"""simple docstring""" import random def SCREAMING_SNAKE_CASE ( snake_case, snake_case, snake_case): __snake_case = a[left_index] __snake_case = left_index + 1 for j in range(left_index + 1, snake_case): if a[j] < pivot: ...
93
"""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 ...
93
1
'''simple docstring''' import numpy as np class lowerCAmelCase__ : """simple docstring""" def __init__( self : Any ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE = (0, 0) __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CAS...
627
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase__ ( unittes...
627
1
def A_ ( A__ = 1000 ) -> int: a__ : List[Any] = -1 a__ : Union[str, Any] = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c a__ : Any = (n * n - 2 * a * n) /...
392
def A_ ( A__ ) -> list[int]: if num <= 0: raise ValueError('Input must be a positive integer' ) a__ : Any = [True] * (num + 1) a__ : Dict = 2 while p * p <= num: if primes[p]: for i in range(...
392
1
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord import VideoReader if ...
655
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 ...
655
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers...
112
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, 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 ...tes...
112
1
'''simple docstring''' def __UpperCamelCase ( a : int , a : int ) ->int: return int((input_a, input_a).count(1 ) != 0 ) def __UpperCamelCase ( ) ->None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_ga...
342
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_...
342
1
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartToken...
714
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device snake_case_ : List[str] = False class _...
644
0
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : int = 400_0000 ) ->int: _SCREAMING_SNAKE_CASE = [0, 1] _SCREAMING_SNAKE_CASE = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break ...
314
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def lowerCamelCase ( __lowerCamelCase : str , __lowerCamelCase : str ) ->str | Literal[False]: _SCREAMING_SNAKE_CASE = list(__lowerCamel...
314
1
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto imp...
716
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
296
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREA...
327
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _a ( SCREAMING_SNAKE_CASE ): ...
191
0
"""simple docstring""" def lowercase (_lowerCAmelCase ): __lowerCAmelCase = [0 for i in range(len(_lowerCAmelCase ) )] # initialize interval's left pointer and right pointer __lowerCAmelCase , __lowerCAmelCase = 0, 0 for i in range(1 , ...
573
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowercase (_lowerCAmelCase ): __lowerCAmelCase = prime_factors(_lowerCAmelCase ) if is_square_free(_lowerCAmelCase ): return -1 if len(_lowerCAme...
573
1
def _a ( UpperCAmelCase ) -> int: """simple docstring""" lowerCamelCase__ : Union[str, Any] = abs(UpperCAmelCase ) lowerCamelCase__ : Union[str, Any] = 0 while n > 0: res += n % 10 n //= 10 return res def _a ( UpperCAmelCase ) ...
315
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_avail...
315
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import...
303
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowercase__( A ): snake_case__ : List[str] = [] embed...
303
1
def UpperCamelCase ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' return "\n".join( F'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=1_0...
12
'''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_modeling...
432
0
import os import sys import unittest a__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init...
578
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a__ = TypeVar('''KEY''') a__ = TypeVar('''VAL''') @dataclass(frozen=__lowercase , slots=__lowercase ) class UpperCAmelCase_ ( Generic[KEY, VAL] ): ""...
578
1
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import to...
28
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class...
28
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __magic_name__ = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotA...
711
from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', # See all Cvt models at https://hug...
73
0
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger __lowerCAmelCase : Optional[Any] = get_logger(__name__) __lowerCAmelCase : Any = R"\n Args:\n inp...
509
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureE...
509
1
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness __snake_case : int ='\\n@misc{chen2021evaluating,\n title={Evaluating Large Lan...
721
from collections.abc import Callable import numpy as np def lowerCAmelCase__ ( lowerCamelCase_ : Callable ,lowerCamelCase_ : float ,lowerCamelCase_ : float ,lowerCamelCase_ : float ,lowerCamelCase_ : float): '''simple docstring''' lowerCAmelCase__ : Dict = int(np.ceil((x_end -...
90
0
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch('socket.socket' ) @patch('builtins.open' ) def lowerCamelCase ( a_ , a_ ) -> str: # ===== initialization ===== lowerCAmelCase_ = Mock() lowerCAm...
318
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 Au...
318
1
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowercase ( lowerCAmelCase : int): """simple docstring""" _A : int = int(number**0.5) return number == sq * sq def lowercase ...
417
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
417
1
'''simple docstring''' # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFor...
296
'''simple docstring''' def _a( UpperCamelCase__ : int = 1_0, UpperCamelCase__ : int = 2_2 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : str =range(1, UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ : List[str] =r...
296
1
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def lowercase ( _a ,_a ,_a ,_a ,) -> list[float]: UpperCAmelCase_ , UpperCAmelCase_: Tuple = coefficient_matrix.shape UpperCAmelCase_ , ...
306
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { """vocab_file""": """vocab.json""", """tokenizer_config_fil...
306
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = {'openai-gpt': 'https://huggingface.co/openai-gpt/resolve/main/config.json'} class __lowercase ...
65
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = {"configuration_plbart": ["PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "PLB...
391
0
"""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 if is_torch_available(): im...
716
"""simple docstring""" from __future__ import annotations def lowerCAmelCase_ ( lowercase_ : int , lowercase_ : int ): '''simple docstring''' if b == 0: return (1, 0) ((__SCREAMING_SNAKE_CASE) , (__SCREAMING_SNAKE_CASE)) : Tuple = ext...
401
0
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( snake_case_): lowerCAmelCase_ = (DDPMScheduler,) def UpperCAmelCase_ ( self , **A_...
3
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase__ : Tuple = logging.get_logger(__name__) UpperCAmelCase__ : List[str] = { "google/umt5-small...
48
0
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCAmelCase__ ( __magic_name__ ): '''simple docstring''' def...
703
def A__ ( __A : int , __A : float , __A : float ) ->float: return round(float(moles / volume ) * nfactor ) def A__ ( __A : float , __A : float , __A : float ) ->float: return round(float((moles * 0.0821 * temperature) / (...
516
0
"""simple docstring""" from __future__ import annotations import time import numpy as np _lowerCAmelCase :Dict = [8, 5, 9, 7] _lowerCAmelCase :Any = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] _lowerCAmelCase :Tuple = [ [3, 2, 1, 4], ...
506
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :Any = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/conf...
506
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _lowerCamelCase : str = logging.get_logger(__name__) _lowerCamelCase : List[Any] = { 'Intel/dpt-large': 'https://...
361
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : Any = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-...
361
1
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( lowercase_ ): __SCREAMING_SNAKE_CASE :int = (DDPMScheduler,) def snake_case__ ( self : Optional[i...
432
'''simple docstring''' def _UpperCamelCase ( lowerCAmelCase__: int ,lowerCAmelCase__: bool = False ) -> bool: if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check ...
294
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class A__ ( _lowerCamelCase): A_ : Optional[Any] = 'SpeechT5FeatureExtractor' A_ : Dict = 'SpeechT5Tokenizer' def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): super()._...
709
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class A__ : def __init__( self ): __lowerCAmelCase : Any = {} def __lowerCamelCase ( self , _SCREAMING_SNAKE_CASE ): __lowerCAmelCase : D...
549
0
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 AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_test...
59
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class __lowerCamelCase : a__: List[str] a__: Optional[str] ...
29
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): """simple docstring""" __a = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): __a = n - k # Calculate C(n,k) for i ...
721
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, ) lowerCamelCase__ = {"""configuration_mbart""": ["""MBART_PRETRAINED_CON...
547
0
import requests _A : str = """YOUR API KEY""" def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ = giphy_api_key ) -> list: SCREAMING_SNAKE_CASE__ = '''+'''.join(query.split() ) SCREAMING_SNAKE_CASE__ = f'''https://api.giphy.com/v1/gif...
100
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 _UpperCAmelCase ( __lowercase ): '''simple docstring...
699
0
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _snake_case ( ): __UpperCAmelCase : str = HfArgumentParser(lowerCamelCase__ ) __UpperCAmelCase : Optional[Any] = parser.parse_args_into_datacl...
710
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
329
0
"""simple docstring""" import math class lowerCAmelCase_ : """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE__=0 ) -> str: # a graph with Node 0,1,...,N-1 """simple docstring""" SCREAMING_SNAKE_CASE__ : ...
223
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed ...
223
1
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import ...
705
'''simple docstring''' from __future__ import annotations import math def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : int ): """simple docstring""" __UpperCAmelCase = u for i in range(1 , UpperCamelCase__ ): __Uppe...
654
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> int: '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def _UpperCamelCase ( ) -> None: '''simple docstring''' ...
638
'''simple docstring''' import numpy as np def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> np.ndarray: '''simp...
638
1
"""simple docstring""" from __future__ import annotations import math def __a ( A , A , A , A , A ) -> int: '''simple docstring''' if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueError("Scores cannot be empty"...
261
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=UpperCAmelCase_ ): lowercase__ : Union[str, Any] = ["""torch""", """transformers""", """onnx"""] def __init__( self , *UpperCamelCase__ , **UpperCamelC...
261
1
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_a...
372
0
"""simple docstring""" import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter ...
361
"""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.pipeline_vq_dif...
361
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension f...
444
'''simple docstring''' import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowerCAmelCase : Optional[int] = datasets.logging.get_logger(__name__) lowerCAmelCase : List[str] = """\ @inprocee...
444
1
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCamelCase_ = '.' # Internal TensorFlow...
701
from __future__ import annotations UpperCamelCase_ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class snake_case_ : '''simple docstring''' ...
510
0
import math import unittest def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" assert isinstance(__A , __A ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or num...
43
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 dep...
475
0
"""simple docstring""" import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vi...
579
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device SCREAMING_SNAKE_CASE_ = False class a ( unittest.Te...
579
1
'''simple docstring''' def __lowercase ( __SCREAMING_SNAKE_CASE ) -> bool: """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __a = sorted(string.lower() ) r...
582
'''simple docstring''' import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import ...
270
0
import warnings from .generation import TFGenerationMixin class A ( UpperCamelCase_ ): '''simple docstring''' warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Tr...
712
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): if n == 1 or not isinstance(snake_case__ , snake_case__ ): return 0 elif n == 2: return 1 else: __UpperCamelCase : str = [0, 1] for i in range(2 , n +...
399
0
'''simple docstring''' import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () A_ = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (trapmf()...
42
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A_ = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetConfig", "ResNetOnnxConfi...
42
1
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE__ : Tuple = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For ...
712
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def a ( UpperCamelCase_ : str , UpperCamelCase_ : List[Any] , UpperCam...
581
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __lowerCAmelCase : Optional[Any] = {"UserAgent": UserAgent().random} def UpperCAmelCase_ ( __lowerCAmelCase ) -> dict: __lowercas...
509
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : Any = logging.get_logger(__name__) __lowerCAmelCase : Optional[Any] = { "vocab_file": ...
509
1
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : bytes ): return "".join([hex(UpperCAmelCase_ )[2:].zfill(2 ).upper() for byte in list(UpperCAmelCase_ )] ) def _snake_case ( UpperCAmelCase_ : str ): # Check data validity, following RFC354...
500
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor SCREAMING_SNAKE_CASE_ : List[Any] = logging.get_logger(__name__) class a ( _lowerCamelCase ): """simple docstring"""...
500
1
"""simple docstring""" from __future__ import annotations a_ = [True] * 1_0_0_0_0_0_1 a_ = 2 while i * i <= 1_0_0_0_0_0_0: if seive[i]: for j in range(i * i, 1_0_0_0_0_0_1, i): a_ = False i += 1 def __UpperCAmelC...
76
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : Union[str, Any] = { 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decision-transformer-gym-ho...
73
0
def a__ ( snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[int] = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def a__ ( snake_case ): """simple...
131
from __future__ import annotations def a__ ( snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[str] = str(snake_case ) return n == n[::-1] def a__ ( snake_case = 1_000_000 ): """simple docstring""" __SCREAMING_SNAKE_CASE ...
131
1
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_common import TokenizerTesterMix...
68
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __A = TypeVar("T") def lowercase__ ( A_: int ) -> int: """simple docstring""" return (position - 1) // 2 def lowercase__ ( A_: int ) -> ...
68
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 im...
579
"""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.md", "dataset_in...
579
1
'''simple docstring''' import math from collections.abc import Iterator from itertools import takewhile def _SCREAMING_SNAKE_CASE ( UpperCamelCase__ : int ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return Tr...
442
'''simple docstring''' import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from d...
442
1
"""simple docstring""" import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_av...
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''' from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.rou...
365
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datase...
657
0
"""simple docstring""" def __lowerCAmelCase( __UpperCAmelCase = 10**12 ): """simple docstring""" _lowercase : Dict = 1 _lowercase : Union[str, Any] = 0 _lowercase : Optional[Any] = 1 _lowercase : Any = 1...
701
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def __lowerCAmelCase( __UpperCAmelCase ): """simple docstring""" if not isinstance(__UpperCAmelCase ,__UpperCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision ...
283
0
"""simple docstring""" a : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_9344, "knot": 1.852, } a : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_7777_7778, "mph": 0.6_2137_1192, "knot": 0.5_3995_6803, } def __magic_na...
273
"""simple docstring""" 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 lowe...
273
1
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "nvidia/segform...
704
import math import sys import cva import numpy as np def __UpperCAmelCase ( UpperCAmelCase, UpperCAmelCase )-> np.ndarray: """simple docstring""" lowercase = math.sqrt(UpperCAmelCase ) lowercase = 1 / (sigma * math.sqrt(2...
479
0
"""simple docstring""" import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def _lowerCamelCase ( __a ): SCREAMING_SNAKE_CASE_ = [ '''encoder.version''', '''decoder.version''', '''model.encoder.versio...
626
lowerCamelCase__ : List[str] = """Alexander Joslin""" import operator as op from .stack import Stack def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> int: snake_case__ = {'''*''': op.mul, '''/''': op.truediv, '''+''': op.add, '''-''': op.sub} sn...
33
0
import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.models.mbart.modeli...
706
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CO...
380
0
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sen...
660
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __snake_case : List[Any] = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block...
660
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ : Optional[Any] = {"""configuration_unispeech""": ["""UNISPEECH_PRETRAINED_...
497
"""simple docstring""" 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 UpperCamelCase_ : Optional[Any] = logging.get_logger(__n...
497
1