code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = {} try: if not is_sentencepiece_availabl...
221
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __UpperCamelCase : str = { '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''Long...
106
0
'''simple docstring''' 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 fro...
190
'''simple docstring''' import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, Bert...
190
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class UpperCAmelCase_ ( a): def snake_case__ ( self, __a): '''simple docstring''' return 0.0 def A ...
36
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": 1}, [range(10 )]), ({"num_s...
36
1
'''simple docstring''' import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokeni...
369
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self , _lowerCamelCase ) -> Optional[Any]: A_ : Any = data ...
164
0
"""simple docstring""" from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge SCREAMING_SNAKE_CASE__ = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say t...
150
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE__ = { "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } t...
150
1
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int , snake_case : int , snake_case : int )-> int: if exponent == 1: return base if exponent % 2 == 0: _lowerCamelCase = _modexpt(snake_case , exponent //...
363
"""simple docstring""" from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE_ ( snake_case : int = 1_500_000 )-> int: _lowerCamelCase = defaultdict(snake_case ) _lowerCamelCase = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: ...
80
0
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging lower...
279
def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase ) -> 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_t...
279
1
"""simple docstring""" import numpy as np from PIL import Image def _snake_case ( _snake_case : np.ndarray , _snake_case : int , _snake_case : int ): lowerCAmelCase : Dict = np.array(_snake_case ) if arr.shape[0] != arr.shape[1]: raise ...
359
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class snake_case_( a__ ): __UpperCamelCase = (DDPMScheduler,) def lowerCamelCase__ ( self : List[Any] , **UpperCamelCase_ :...
314
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'BAAI/AltCLIP': 'https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json', # See all AltCLIP models at...
30
from __future__ import annotations def a ( snake_case__: list[int] , snake_case__: int , snake_case__: int , snake_case__: int ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and...
30
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : Optional[Any] = { 'configuration_roberta': ['ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP'...
360
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( FlaxForcedBOSTokenLogitsPr...
49
0
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase ) -> List[Any]: lowercase__ : str = (boundary[1] - boundary[0]) / steps lowercase__ : Optional[int] = boundary[0] lowercase__ : Any = boundary[...
16
import math def snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' lowercase__ : Optional[Any] = [] lowercase__ : str = 2 lowercase__ : Optional[Any] = int(math.sqrt(SCREAMING_SNAKE_CASE_ ) ) # Size of ever...
214
0
'''simple docstring''' 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.mode...
352
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar a__ : int = TypeVar('T') class UpperCAmelCase__ (...
243
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def _SCREAMING_SNAKE_CASE ( a , a , a = False ) -> list[float]: if radian_mode: return [magnitude * cos(a ), magnitude * sin(a ...
280
from heapq import heappop, heappush import numpy as np def _SCREAMING_SNAKE_CASE ( a , a , a , a , ) -> tuple[float | int, list[tuple[int, int]]]: __A , __A : int = grid.shape __A : Any = [-1, 1, 0, 0] __A...
280
1
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class __snake_case( _lowerCAmelCase ): '''simple docstring''' def __snake_case ( self ) -> Tuple: return [ ...
187
'''simple docstring''' class __snake_case( _lowerCAmelCase ): '''simple docstring''' pass class __snake_case( _lowerCAmelCase ): '''simple docstring''' pass class __snake_case: '''simple docstring''' d...
187
1
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int = 1000 ) -> int: UpperCAmelCase_ : Union[str, Any] = 2**power UpperCAmelCase_ : List[Any] = 0 while n: UpperCAmelCase_ , UpperCAmelCase_ : Opti...
125
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_a...
125
1
'''simple docstring''' def _a( UpperCamelCase__ : int = 1_0_0_0_0_0_0 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : str =1 SCREAMING_SNAKE_CASE__ : str =1 SCREAMING_SNAKE_CASE__ : Optional[A...
353
'''simple docstring''' import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py a_ = 'src/diffusers' # Matches is_xxx_available() a_ = re.compile(R'is\_([a-z_]*)_avail...
222
0
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common ...
35
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : Dict ={ '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if ...
41
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __lowercase ( unittest.TestCase ): """simple docstring""" UpperCamelCase : Dict = JukeboxTokenizer UpperCamelCase : Any = { "arti...
350
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 __lowerc...
66
0
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def __lowercase ( a__ , a__ , a__ , ...
257
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCAmelCase__ : List[Any] =input('''Enter image url: ''').strip() print(F'''Downloading image from {url} ...''') lowerCAmelCase__ : int =BeautifulSoup(requests.get(u...
257
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase_ (metaclass=a__ ): """simple docstring""" _lowerCAmelCase = ['keras_nlp'] def __init__( self : Optional[Any] , *_lowerCamelCase : D...
361
'''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/...
4
0
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets lowercase__ : Union[str, Any] = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation",...
190
'''simple docstring''' lowercase__ : Dict = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', ...
190
1
"""simple docstring""" import os import sys import unittest lowerCamelCase_ = 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...
239
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kinetics400/resolv...
239
1
import torch from diffusers import DiffusionPipeline class lowercase ( __UpperCAmelCase ): def __init__( self ,A__ ,A__): super().__init__() self.register_modules(unet=lowerCamelCase__ ,scheduler=lowerCamelCase__) def __call__( self): ...
101
'''simple docstring''' import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class A ( __UpperCAmelCase ): lowerCamelCase : Union[str, Any] = """MCTCTFeatureExtractor""" lowerCamelCase : Dict = ""...
164
0
def lowerCAmelCase_ ( UpperCamelCase_ = 1000 ) -> int: UpperCamelCase_ = 3 UpperCamelCase_ = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a ...
328
import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> str: UpperCamelCase_ = BeautifulSoup(requests.get(UpperCamelCase_ , params=UpperCamelCase_ ).content , "html.parser" ) UpperCam...
328
1
'''simple docstring''' 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, ) if is_sentencepiece_available(): from ..ta.to...
83
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np a__ : Optional[int] = re.compile(R'\b(a|an|the)\b', re.UNICODE) a__ : int = None def _UpperCamelCase ( ) -> Dict...
80
0
"""simple docstring""" 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 AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils ...
364
"""simple docstring""" from __future__ import annotations from typing import Any def A ( snake_case :list ) -> int: if not postfix_notation: return 0 __UpperCamelCase = {'+', '-', '*', '/'} __UpperCamelCase = [] for token in postfix_notation: if token in operations...
263
0
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_rouge, chunks, pars...
281
import numpy as np from PIL import Image def UpperCAmelCase_ ( _A , _A , _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = np.array(_A ) if arr.shape[0] != arr.shape[1]: raise ValueError('''The input array is not a square matrix''' ) SCR...
314
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ : int = logging.get_logger(__name__) lo...
352
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, req...
215
0
from collections.abc import Generator from math import sin def __A ( __lowerCAmelCase )-> Union[str, Any]: """simple docstring""" if len(_UpperCAmelCase ) != 32: raise ValueError('Input must be of length 32' ) _UpperCAmelCase = b...
39
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __snake_case :Optional[int] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generati...
49
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer UpperCAmelCase_ : Optional[Any] = logging.get_logger(__n...
352
import os from collections import deque import torch from torch.utils.data import Dataset class SCREAMING_SNAKE_CASE__ ( lowercase__ ): def __init__( self : Tuple , SCREAMING_SNAKE_CASE__ : List[Any]="" , SCREAMING_SNAKE_CASE__ : Union[str, Any]="train" ) ...
120
0
"""simple docstring""" def _snake_case ( lowercase__ : dict ) -> set: '''simple docstring''' lowerCAmelCase_ :Any = set() # edges = list of graph's edges lowerCAmelCase_ :List[Any] = get_edges(lowercase__ ) # While there are st...
84
"""simple docstring""" from __future__ import annotations class snake_case : def __init__( self , __UpperCAmelCase) ->Any: a_ = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least one and the same numb...
243
0
import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def A ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ...
344
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/lev...
344
1
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase__ : Optional[int] = {"tokenization_wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lo...
187
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowercase__ : Optional[int] = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weight", "time...
187
1
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder UpperCAmelCase = """__DUMMY_TRANSFORMERS_USER__""" UpperCAmelCase = """Dummy User""" UpperCAmelCase = """hf_hZEmnoOEYISjraJtbySaKCNnSuYAv...
370
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_diffusion import LearnedClassifierFreeSampli...
267
0
"""simple docstring""" import requests from bsa import BeautifulSoup def __lowerCAmelCase (_UpperCamelCase = "https://www.worldometers.info/coronavirus" ): __lowerCAmelCase : Optional[int] = BeautifulSoup(requests.get(_UpperCamelCase ).text , 'html.parser' ) __lowerCAmelCa...
86
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : List[Any] = log...
222
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : Tuple = { "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"], "conve...
362
import re import string import numpy as np import datasets snake_case : Any = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" snake_case : Optional[Any] = "\nArgs:\n predict...
41
0
"""simple docstring""" from __future__ import annotations def A_ ( _lowercase ): '''simple docstring''' if len(_lowercase ) == 0: return [] snake_case_, snake_case_ :Tuple = min(_lowercase ), max(_lowercase ) snake_case_ :Tuple = int(max_value -...
66
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { "configuration_mobilebert": [ "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
66
1
from __future__ import annotations def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase ): if len(__lowerCamelCase ) == 0: return False _SCREAMING_SNAKE_CASE : List[Any] = len(__lowerCamelCase ) // 2 if a_list[midpoint] == item: return ...
371
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class lowerCAmelCase__( __lowercase , __lowercase ...
325
0
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _a ( UpperCamelCase_ : Dict ) -> Dict: """simple docstring""" lowerCAmelCase__ ...
340
'''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/lice...
4
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 _A = logging.get_logger(__name__) _A = { 'facebook/levit-128S': 'https://huggingface.co/f...
117
from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=A_ ): """simple docstring""" UpperCAmelCase__ : Any = ["speech"] def __init__( self , *A_ , **A_ ) -> Any: requires_backends(self , ['speec...
117
1
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list ) -> list: if any(not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in ...
239
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list ) -> list: if any(not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in ...
239
1
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : Any , SCREAMING_SNAKE_CASE__ : List[Any] ): return number | (1 << position) def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : int ): return number & ~(1 << pos...
358
from __future__ import annotations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): if b == 0: return (1, 0) ((__UpperCamelCase) , (__UpperCamelCase)) =extended_euclid(SCREAMING_SNAKE_CASE__ , a % ...
117
0
def A_ ( snake_case : int = 1000 ) -> int: '''simple docstring''' __UpperCamelCase = 3 __UpperCamelCase = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: ...
328
def A_ ( snake_case : list ) -> list: '''simple docstring''' __UpperCamelCase = len(snake_case ) for i in range(1 , snake_case ): __UpperCamelCase = collection[i] __UpperCamelCase = 0 ...
328
1
"""simple docstring""" import argparse import datetime import io import itertools import json import math import os import platform import re import shlex import subprocess import sys from pathlib import Path from statistics import fmean import pandas as pd import torch from tqdm import tqdm import trans...
357
"""simple docstring""" from ...processing_utils import ProcessorMixin class lowerCAmelCase__ ( UpperCAmelCase__ ): '''simple docstring''' __UpperCamelCase = "SpeechT5FeatureExtractor" __UpperCamelCase = "SpeechT5Tokenizer" def __init__( ...
318
0
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch lowerc...
7
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _UpperCAmelCase : List[str] = str(bin(UpperCamelCase__ ) ...
263
0
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( A__ , A__ , A__ ) -> tuple[float, list[float]]: """simple docstring""" UpperCamelCase = list(range(len(A__ ) ) ) UpperCamelCase = [v /...
368
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from tra...
249
0
'''simple docstring''' from heapq import heappop, heappush import numpy as np def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase , ) -> tuple[float | int, list[tuple[int, int]]]: lowerCamel...
41
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule A_ : int = {"""tokenization_bertweet""": ["""BertweetTokenizer"""]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys A_ : int = _LazyModule(__...
215
0
"""simple docstring""" import socket def lowercase__ ( ): __UpperCAmelCase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) __UpperCAmelCase = socket.gethostname() __UpperCAmelCase = 12_312 sock.connect((host, port) ) sock.send(b'''Hello server...
357
"""simple docstring""" from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ...
86
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __lowercase = { '''configuration_speech_to_text''': ['''SPEECH_TO_TEXT_PRETRAINED_CONFIG_...
43
'''simple docstring''' 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 AutoFeatureExtractor, WavaVecaFeatureExtractor from ...
120
0
"""simple docstring""" from __future__ import annotations lowercase__ : Optional[int] = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __lowercase ( _a , _a , _a , _a , _a , ): snake_case_ : Optional[i...
155
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
155
1
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase ( a_ , a_ , a_ , a_ ) ...
344
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def UpperCAmelCase ( a_ ) -> Dict[str, torch.Tensor]: """simple docstring""" ...
344
1
"""simple docstring""" def _A ( UpperCamelCase_ : int) -> None: '''simple docstring''' __lowercase = generate_pascal_triangle(UpperCamelCase_) for row_idx in range(UpperCamelCase_): # Print left spaces for _ in range(num_rows - row_idx - 1): print(end=...
144
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class _lowerCAmelCase ( lowercase ): """simple docstring""" def __init__( self : List[str], UpperCAmelCase__ ...
144
1
'''simple docstring''' # 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.multicontrolnet import MultiControlNetModel # noqa: F401 from ..contro...
35
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from trans...
267
0
from math import ceil def _UpperCamelCase (a__ :Any = 1001 ): """simple docstring""" UpperCamelCase__ = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): UpperCamelCase__ = 2 * i + 1 UpperCamel...
371
from datetime import datetime as dt import os from github import Github UpperCamelCase__ = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def _UpperCamelCase (): """simple docstring""" ...
87
0
"""simple docstring""" from maths.prime_check import is_prime def _lowerCAmelCase ( UpperCamelCase_ ): if not isinstance(UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = f"Input value of [number={number}] must be an integer" raise TypeError(UpperCamelCase...
100
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : Dict ={ '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if ...
41
0
from collections import defaultdict class a : """simple docstring""" def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ ) -> Optional[Any]: _A = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N ...
81
# 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...
81
1
import os import pytest from transformers.dynamic_module_utils import get_imports _SCREAMING_SNAKE_CASE = """ import os """ _SCREAMING_SNAKE_CASE = """ def foo(): import os return False """ _SCREAMING_SNAKE_CASE = """ def foo(): def bar(): ...
327
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE__ = { """facebook/mask2former-swin-small-coco-instance""": ( """https://huggingface.co/facebook/mask2former...
325
0
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( ...
366
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching bet...
213
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case__ : Optional[Any] = logging.g...
117
def _a ( lowerCamelCase: int = 2_00 ) -> int: '''simple docstring''' __A = [1, 2, 5, 10, 20, 50, 1_00, 2_00] __A = [0] * (pence + 1) __A = 1 # base case: 1 way to make 0 pence for coin in coins: ...
117
1
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def lowerCamelCase__ ( __lowerCamelCase : np.ndarray , __lowerCamelCase : np.ndarray ): '''simple docstring''' return math.sqrt(sum(pow(a ...
360
'''simple docstring''' lowercase =[0, 2, 4, 6, 8] lowercase =[1, 3, 5, 7, 9] def lowerCamelCase__ ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : list[int] , __lowerCamelCase : int ): '''simple docstring''' i...
242
0
import copy import random from transformers import CLIPTokenizer class __A ( a ): """simple docstring""" def __init__( self , *lowerCamelCase__ , **lowerCamelCase__ ): """simple docstring""" super().__i...
71
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() snake_case__ : Dict = logging.get_logger(__name__) snake_case__ : Optional[Any] ...
117
0
'''simple docstring''' 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...
98
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils ...
98
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_camembert im...
188
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
318
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils ...
360
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class A_ (lowercase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__...
23
0
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a : Any ...
56
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
'''simple docstring''' def A_( A : list): if any(not isinstance(__lowerCamelCase , __lowerCamelCase) or x < 0 for x in sequence): raise TypeError('Sequence must be list of non-negative integers') for _ in range(len(__lowerCamelCase)): for i, (r...
360
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : Union[str, Any] = {'openai-gpt': 'https://huggingface.co/openai-gpt/resolve/main/config.json'} class...
251
0
import re from filelock import FileLock try: import nltk A_ :Any = True except (ImportError, ModuleNotFoundError): A_ :Union[str, Any] = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download...
71
"""simple docstring""" import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import clas...
86
0
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A_ (UpperCamelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] = ["""image_processor""", """tokenizer"""] SCREAMING_SNAKE_CASE__ ...
367
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class A_ (lowercase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : str = (PNDMScheduler,) SCREAMING_SNAKE_CASE__ : str ...
23
0
"""simple docstring""" def lowercase (snake_case__ : int = 1_000 ) -> int: '''simple docstring''' lowerCAmelCase = 3 lowerCAmelCase = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a ...
155
"""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, PreTrained...
155
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_time_series_transformer': [ 'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimeSeriesTransformerConfig', ], } try: if not is_torch_avai...
50
from timeit import timeit a_ = { 'MALAYALAM': True, 'String': False, 'rotor': True, 'level': True, 'A': True, 'BB': True, 'ABC': False, 'amanaplanacanalpanama': True, # "a man a plan a canal panama" } # Ensure our test data is valid assert all((key == key[::-1]) is value for key, va...
50
1
"""simple docstring""" def _snake_case ( lowerCamelCase__ : int , lowerCamelCase__ : int ) -> str: if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) lowerCamelCase_ : Dict =str(bin(lowerCamelCase__ ) ...
144
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _snake_case ( lowerCamelCase__ : T...
144
1
"""simple docstring""" from ...processing_utils import ProcessorMixin class __snake_case ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" _lowerCamelCase = """WhisperFeatureExtractor""" _lowerCamelCase = """WhisperTokenizer""" def __init__( self , __lowerCamelCas...
364
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a_ = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """BloomOnnxConfig"""], } try: ...
291
0
'''simple docstring''' def _lowerCamelCase ( lowercase : str ) -> list: if n_term == "": return [] _a = [] for temp in range(int(lowercase ) ): series.append(F'1/{temp + 1}' if series else "1" ) return series if __name__ == "__main_...
63
import operator def lowercase_ ( _lowerCamelCase : list , _lowerCamelCase : bool = False , _lowerCamelCase : list | None = None): lowercase__ : int = operator.lt if reverse else operator.gt lowercase__ : str = solution or [] if ...
87
0
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, ...
358
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_...
39
0
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config ...
81
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ : Union[str, Any] = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHI...
81
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { '''RUCAIBox/mvp''': '''https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json''', } class lowercase_ ( __lowercase ): UpperC...
278
from math import factorial def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> int: """simple docstring""" if n < k or k < 0: raise ValueError('''Please enter positive integers for n and k where n >= k''' ) return factorial(_UpperCamelCase ) // (factorial(_UpperCam...
278
1
"""simple docstring""" from manim import * class lowerCAmelCase_ ( lowercase_ ): """simple docstring""" def snake_case ( self ): """simple docstring""" snake_case = Rectangle(height=0.5 , width=0.5 ) snake_case...
150
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase ( yaml.SafeLoader ): def _UpperCAmelCase ( self ,__UpperCamelCase ) -> Optional[int]: '''simple docstring''' ...
213
0
'''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...
48
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class _UpperCamelCase : '''simple docstring''' def __init__( self : List[Any]): '''simple docstring''' __lowercase =[] ...
48
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _a = { "configuration_clip": [ "CLIP_PRETRAINED_CONFIG_...
209
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( ...
242
0
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ...
29
def lowerCamelCase__ ( A__ : list ): '''simple docstring''' for i in range(len(A__ ) - 1 , 0 , -1 ): __lowerCamelCase = False for j in range(A__ , 0 , -1 ): if unsorted[j] < unsorted[j -...
29
1
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils impor...
98
"""simple docstring""" import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) lowerCAmelCase__ : Optional[Any] ...
98
1
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
365
"""simple docstring""" import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from fl...
23
0
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowercase( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ = None ) -> str: '''simple docstring''' if version.parse(hfh.__version__ ).release < ve...
343
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, ...
23
0
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = 42 __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = None a__: Dict ...
39
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( UpperCamelCase__ ): __SCREAMING_SNAKE_CASE = '''MCTCTFeatureExtractor''' __SCREAMING_SNAKE_CASE = '''AutoTokenizer''' ...
39
1
'''simple docstring''' def a_ ( lowerCamelCase : list[int] , lowerCamelCase : list[int] , lowerCamelCase : int ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(lowerCamelCase ) ) def a_ ( lowerCa...
4
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "toke...
251
0
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
286
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, ...
286
1
"""simple docstring""" from math import factorial def _SCREAMING_SNAKE_CASE ( _lowercase : int = 100 ) ->int: '''simple docstring''' return sum(map(_lowercase , str(factorial(_lowercase ) ) ) ) if __name__ == ...
105
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, Wav...
23
0
"""simple docstring""" from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers im...
352
def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Dict = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
319
0
import numpy # List of input, output pairs _UpperCAmelCase : Union[str, Any] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Dict = (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) _UpperCAmelCase ...
50
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 SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> int: lowerCamelCase...
50
1
"""simple docstring""" import numpy as np lowercase__ = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""",...
161
"""simple docstring""" import json from typing import TYPE_CHECKING, 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 .tokeni...
161
1
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, ...
12
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __magic_name__ ( UpperCAmelCase__ ): '''simple docstring''' def __init__( self , _a , _a , _a ): ...
291
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Dict = logging.get_logger(__name__) __UpperCamelCase : Optional[Any] = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20...
309
"""simple docstring""" import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __UpperCamelCase : List[Any] = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets b...
309
1
'''simple docstring''' from __future__ import annotations from fractions import Fraction def __a(SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : Optional[int] ): '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den...
158
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_to...
39
0
def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): __a = '' for word_or_phrase in separated: if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise Exception('join() accepts only strings to be joined' ) joine...
197
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase_ : Dict = {"""configuration_speech_encoder_decoder""": ["""SpeechEncoderDecoderConfig"""]} try: if not is_torch_available(): raise OptionalDep...
197
1
from math import asin, atan, cos, radians, sin, sqrt, tan _A = 6_378_137.0 _A = 6_356_752.314_245 _A = 6_378_137 def __UpperCamelCase ( _A , _A , _A , _A ): lowerCAmelCase_ = (AXIS_A - AXIS_B) / AXIS_A lowerCAmelCase_ = atan((1 - flattening) * tan(r...
278
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = 1 lowerCAmelCase_ = 1 lowerCAmelCase_ = {1: 1} for inputa in range(2 , _A ): lowerCAmelCase_ = 0 lowerCAmelCase_ = inputa while True: ...
278
1
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline __A = version.parse(version.parse(torch.__version__).base...
363
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def __A ( _lowercase , _lowercase , _lowercase ): '''simple docstring''' _A = ('''dense.weight''', '''attention.self.query''', '''attenti...
75
0
import operator as op def A ( _SCREAMING_SNAKE_CASE ) -> Union[str, Any]: lowerCamelCase : Any = [] lowerCamelCase : List[str] = lambda _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE : int(x / y ) # noqa: E731 integer division operation ...
48
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(lowerCAmelCase__ ...
48
1
from dataclasses import dataclass, field from typing import Optional @dataclass class SCREAMING_SNAKE_CASE_ : __lowerCAmelCase = field( default="""codeparrot/codeparrot""" , metadata={"""help""": """Model name or path of model to be trained."""} ) __lowerCAmelCase = ...
165
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from transformers.util...
165
1
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-research/ef...
29
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def lowercase__ ( ...
29
1
from __future__ import annotations import requests UpperCamelCase__ =set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories created_utc down...
351
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever UpperCamelCase__ =logging.getLogger(__name__) class lowerCAmelCase__( __lowercase ): '''simple docstri...
325
0