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""" print((lambda quine: quine % quine)('print((lambda quine: quine %% quine)(%r))'))
16
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(snake_case__ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('''doctest''').testmod(...
298
0
"""simple docstring""" from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo A_ : List[Any] = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n ...
365
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class a_ ( snake_case_ ): '''simple docstring''' @staticmethod @abstractmethod def a__ (lowerCamelCase_ ): '''simple docstring''' raise NotImp...
316
0
'''simple docstring''' import math class _lowerCAmelCase : """simple docstring""" def __init__( self , _lowerCamelCase=0 ) -> Optional[int]: # a graph with Node 0,1,...,N-1 A_ : Optional[Any] = n A_ : List[str] = [ [math.inf for j in ran...
344
'''simple docstring''' def UpperCAmelCase ( a_ = 1_0_0 ) -> int: """simple docstring""" A_ : Dict = n * (n + 1) * (2 * n + 1) / 6 A_ : Optional[int] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __n...
344
1
def __UpperCamelCase ( _A = 1000000 ): lowerCAmelCase_ = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , _A ): phi[j] -= phi[j] // i return...
167
import pprint import requests _A = '''https://zenquotes.io/api''' def __UpperCamelCase ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def __UpperCamelCase ( ): return requests.get(API_ENDPOINT_URL + '''/random''' ).json() if __name__ == "__main_...
167
1
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : int = 1000 ) -> int: """simple docstring""" return sum(e for e in range(3 , __magic_name__ ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F'''{solution() = }''')
38
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 import require_tensorflow_text, re...
38
1
'''simple docstring''' UpperCamelCase__ : dict[tuple[int, int, int], int] = {} def UpperCAmelCase ( a_ , a_ , a_ ) -> int: """simple docstring""" if late == 3 or absent == 2: return 0 # if we have no days left...
164
'''simple docstring''' import math def UpperCAmelCase ( a_ ) -> list: """simple docstring""" A_ : List[Any] = [True] * n A_ : List[Any] = False A_ : Union[str, Any] = False A_ : List[Any] ...
164
1
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_b...
205
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() __A =logging....
19
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _UpperCAmelCase = {'UserAgent': UserAgent().random} def lowerCAmelCase_ ( UpperCamelCase_ ) -> dict: UpperCamelCase_ = script.conte...
328
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_deter...
328
1
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
44
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : Optional[int] = logging.get_logger(__name__) class snake_case ( __UpperCAmelCase ): ...
98
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_ ) -> float: """simple docstring""" return math.sqrt(sum(pow(a - b, 2 ) for a, b in zip(snake...
365
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : List[str] = { """snap-research/efficientformer-l1-300""": ( """https:/...
330
0
'''simple docstring''' def _lowerCamelCase ( lowercase : Dict = 400_0000 ) -> Any: _a = [0, 1] _a = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 _a = 0 for j in rang...
63
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """studio-ousia/luke-base""": """https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json""", """studio-ousia/luke-large...
303
0
from jiwer import compute_measures import datasets UpperCAmelCase : Optional[int] = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evalu...
66
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging UpperCAmelCase : str =...
66
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE (A , A ) -> Tuple: """simple docstring""" lowercase__ = (boundary[1] - boundary[0]) / steps lowercase__ = boundary[0] lowercase__ = boundary[1] lowercase__ = make_...
2
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultis...
265
0
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuratio...
336
"""simple docstring""" import argparse from collections import defaultdict def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): _lowercase : str = F"""{file}_{class_name}_{test_n...
336
1
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) def UpperCAmelCase__ (UpperCamelCase_ ): """simple docstring""" if ...
127
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _SCREAMING_SNAKE_CASE : Optional[Any] = 2_00 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst...
127
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowerCamelCase = {'configuration_vit_mae': ['VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMAEConfig']} ...
177
import numpy as np def SCREAMING_SNAKE_CASE ( __UpperCamelCase : np.array ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
177
1
import random def A ( a_ ,a_ ,a_ = False ) -> dict: __UpperCamelCase : dict ={i: [] for i in range(a_ )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
71
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :Any = logging.get_logger(__name__) A_ :int = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT...
71
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_time_series_transformer": [ "TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimeSeriesTransf...
310
"""simple docstring""" lowerCamelCase__ = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def lowercase__ ( lowercase_ ,lowercase_ ,lowercase_ ,lowercase_ ) -> ...
310
1
from itertools import product def _UpperCamelCase ( snake_case__, snake_case__ ) -> list[int]: __UpperCAmelCase : List[str] = sides_number __UpperCAmelCase : int = max_face_number * dice_number __UpperCAmelCase : Any = [0] * (max_...
157
import argparse import os import re _snake_case = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict _snake_case = re.compile(r'''[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDi...
157
1
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowercase : Tuple = argparse.ArgumentParser() parser.add_argument( ...
311
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availa...
311
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVec...
83
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase : List[Any] = { """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama...
307
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
34
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ ...
34
1
import argparse import gc import json import os 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 from accelerate import Accelera...
103
import argparse import os import re import packaging.version A__ : Dict = '''examples/''' A__ : Any = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.compile(R'''^__version__\s+=\s+"([^...
103
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowercase__ : Optional[int] = logging.get_logger(__name__) lowercase__...
353
def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> bool: a = 0 a = number while duplicate > 0: a , a = ...
180
0
"""simple docstring""" def _A (__a , __a ) -> float: """simple docstring""" def get_matched_characters(__a , __a ) -> str: SCREAMING_SNAKE_CASE_ : str = [] SCREAMING_SNAKE_CASE_ : Union[str, Any] = min(len(_s...
91
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
247
0
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...util...
355
"""simple docstring""" import inspect import unittest from transformers import YolosConfig 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_configura...
215
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { 'configuration_electra': ['ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Electr...
11
"""simple docstring""" from typing import Any class a : def __init__( self : Tuple , __SCREAMING_SNAKE_CASE : Any ) -> List[Any]: lowerCamelCase_ = data lowerCamelCase_ = ...
183
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging a__ : Tuple ...
352
"""simple docstring""" from __future__ import annotations import requests def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' __SCREAMING_SNAKE_CASE = f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return request...
195
0
'''simple docstring''' from __future__ import annotations import numpy as np def a ( __a ) -> Union[str, Any]: '''simple docstring''' return np.maximum(0 , __a ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
97
'''simple docstring''' import re from filelock import FileLock try: import nltk __snake_case = True except (ImportError, ModuleNotFoundError): __snake_case = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=True) def a...
97
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffus...
86
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowercase : int = logging.get_logger(__name__) _lowercase : Tuple ...
86
1
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Tuple: '''simple docstring''' if len(_UpperCAmelCase ) == 0: return [] lowerCAmelCase : int = min(_UpperCAmelCase ), max(_UpperCAmelCase ) lowerCAmelCase : Optional[int] ...
138
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...
95
0
"""simple docstring""" def _lowerCAmelCase ( UpperCAmelCase : int ): '''simple docstring''' assert ( isinstance(UpperCAmelCase , UpperCAmelCase ) and number_of_steps > 0 ), F'''number_of_steps needs to be positive integer, your input {number_of_steps}'''...
157
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/li...
157
1
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, r...
82
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as Prophet...
121
0
def A__ ( SCREAMING_SNAKE_CASE__) -> str: __snake_case: Any = abs(SCREAMING_SNAKE_CASE__) __snake_case: Optional[int] = 0 while n > 0: res += n % 10 n //= 10 return res def A__ ( SCREAMING_SNAKE_CASE__) -> Optional[Any]...
367
import inspect import unittest from transformers import MobileViTConfig 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_configuration_common import ConfigTester from ...t...
293
0
import math def lowerCAmelCase_ ( ): __snake_case : Any = input("Enter message: " ) __snake_case : List[Any] = int(input(F'Enter key [2-{len(_UpperCAmelCase ) - 1}]: ' ) ) __snake_case : List[str] = input("Encryption/Decryption [e/d]: " ) ...
123
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, ...
137
0
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __A ( tf.keras.layers.Layer ): def __init__(self : str , __a : int , __a : Optional[int] , __a : Union[str, Any] , __a : Dict , __...
106
'''simple docstring''' 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 BartForConditiona...
106
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
216
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ ={ 'configuration_roformer': ['ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoFormerConfi...
216
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) _UpperCAmelCase : Optional[int] = { """edbeeching/decision-transformer-gym-hopper-medium""": ( ...
9
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets _UpperCAmelCase : List[str] = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the gro...
9
1
import argparse import os from accelerate.utils import ComputeEnvironment from .cluster import get_cluster_input from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file # noqa: F401 from .config_utils import _ask_field, _ask_options, _convert_compute_envi...
310
'''simple docstring''' import functools def __UpperCAmelCase ( A : str , A : str ) -> int: UpperCAmelCase_ : Optional[Any] = len(A ) UpperCAmelCase_ : List[str] = len(A ) @functools.cache def min_distance(A : int , A : ...
304
0
from __future__ import annotations class __magic_name__ : def __init__( self , _lowercase = 0 )-> Optional[Any]: UpperCamelCase_ = key def UpperCAmelCase_ ( self , _lowercase , _lowercase )->...
358
from ...processing_utils import ProcessorMixin class __magic_name__ ( snake_case ): UpperCamelCase_ :str = """SpeechT5FeatureExtractor""" UpperCamelCase_ :Optional[int] = """SpeechT5Tokenizer""" def __init__( self , ...
60
0
SCREAMING_SNAKE_CASE :dict[tuple[int, int, int], int] = {} def UpperCAmelCase ( a_ , a_ , a_ ) -> List[Any]: """simple docstring""" if late == 3 or absent == 2: return 0 # if we have no days left, and have not failed any other rules, # we have a ...
15
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar UpperCAmelCase : Dict =TypeVar("""T""") class _lowercase (Generic[T] ): '''simple docstring''' def __init__( self , snake_case__ ): ...
128
0
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.append(os.path...
363
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, AutoTo...
47
0
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, PreTrainedTokenizerBase, TensorType ...
10
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup a = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def lowercase (snake_case__ : str = "mumbai" ) -...
155
0
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCamelCase ( lowerCAmelCase : BertModel , lowerCAmelCase : str , lowerCAmelCase : str ): """simple docstring""" ...
359
'''simple docstring''' import math def lowerCamelCase ( lowerCAmelCase : float , lowerCAmelCase : float ): """simple docstring""" return math.pow(lowerCAmelCase , 2 ) - a def lowerCamelCase ( lowerCAmelCase : float ): """simple docstring"...
275
0
import pytest __A = "__dummy_dataset1__" __A = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", \"validation\": REPO_URL + \"wiki...
90
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available(): ...
186
0
'''simple docstring''' import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCamelCase__ ( __lowerCamelCase : int , _...
242
'''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
1
def __A ( __lowerCAmelCase , __lowerCAmelCase )-> Union[str, Any]: """simple docstring""" _UpperCAmelCase = (boundary[1] - boundary[0]) / steps _UpperCAmelCase = boundary[0] _UpperCAmelCase = boundary[1] _UpperCAmel...
39
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import Back...
329
0
'''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 get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_te...
367
'''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_diffusion import Lear...
332
0
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): impor...
274
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 : Optional[Any] = logging...
274
1
'''simple docstring''' def snake_case__ ( lowerCamelCase__ : Any ) -> bool: return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("""Program to check whether a number is a Perfect num...
352
'''simple docstring''' import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline snake_case...
4
0
"""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_modeli...
294
"""simple docstring""" import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_s...
294
1
"""simple docstring""" import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_co...
336
"""simple docstring""" from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import * ...
336
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : str =logging.get_logger(__name__) __lowerCAmelCase : str ={ 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/res...
9
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, nes...
9
1
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCAmelCase = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCAmelCase = [ord(letter) for letter in string.asci...
172
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowerCamelCase (a_ :List[Any]) -> ...
172
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "facebook/vit-mae-base": "https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json", # See all ViT MAE models at https://huggingface.co/models?f...
10
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
53
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ :List[str] = { "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], } try: if not is_torch_available(...
97
lowercase__ :List[str] = 6_5521 def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = 1 lowercase = 0 for plain_chr in plain_text: lowercase = (a + ord(lowerCAmelCase__ )) % MOD_ADLER lowerca...
97
1
"""simple docstring""" def _lowerCAmelCase ( lowercase_ = 1000 ): UpperCAmelCase , UpperCAmelCase = 1, 1 UpperCAmelCase = 2 while True: UpperCAmelCase = 0 UpperCAmelCase = fa + fa ...
78
'''simple docstring''' from maths.prime_factors import prime_factors def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): lowerCAmelCase__ : int = f"""Input value of [number={num...
37
0
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_t...
368
"""simple docstring""" from __future__ import annotations class __lowerCamelCase : def __init__(self , lowerCamelCase , lowerCamelCase ): '''simple docstring''' _lowerCAmelCase , _lowerCAmelCase = text, pattern _lowerCAmelCase , _low...
317
0
def lowerCAmelCase_ ( __a , __a , __a ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__a ) ) def lowerCAmelCase_ ( __a , __a , __a , __a ) -> bool: ...
10
from __future__ import annotations def UpperCAmelCase_ ( _A , _A = None ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = word_bank or [] # create a table SCREAMING_SNAKE_CASE__ = len(_A ) + 1 SCREAMING_SNAKE_CASE__ = [] for _ in range(...
314
0
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowerCAmelCase_ : Tuple = { '''linear''': PIL.Image.Resampling.BILINEAR, ...
351
"""simple docstring""" 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 lowerCAmelCase_ : Tuple ...
248
0
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .schedul...
213
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_...
279
0
import doctest from collections import deque import numpy as np class _SCREAMING_SNAKE_CASE : def __init__( self : str ): UpperCamelCase :Optional[int] = [2, 1, 2, -1] UpperCamelCase :List[str] = [1, 2, 3, 4] def _A ( self : Union[str, An...
62
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...im...
62
1
import os import string import sys UpperCAmelCase_ = 1 << 8 UpperCAmelCase_ = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLAG, 'left': 68 + ARROW_KEY_FLAG, 'mod_int': 91, ...
12
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : int = 100 ) -> int: """simple docstring""" lowerCAmelCase_ : Any = (n * (n + 1) // 2) ** 2 lowerCAmelCase_ : Optional[int] = n * (n + 1) * (2 * n + 1) // 6 r...
224
0
"""simple docstring""" def _a ( _snake_case ): """simple docstring""" if upper_limit < 0: raise ValueError("""Limit for the Catalan sequence must be ≥ 0""" ) UpperCAmelCase = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 ...
356
"""simple docstring""" import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( ...
234
0
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def _SCREAMING_SNAKE_CASE (A , A , A ) -> List[Any]: """simple docstring""" lowercase__ = OmegaConf.load(A ...
2
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py __snake_case ="""\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, ti...
4
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): ...
180
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class a__ ( UpperCamelCase__ , unittest.Test...
180
1
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
163
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class a (_lowerCAmelCase ): """simple docstring""" def __init__( self : Tuple , lowerCamelCase : List[str] , lowerCamelCase : ...
123
0
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel ...
352
'''simple docstring''' import functools def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): # Validation if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or not all(isinstance(UpperCamelCase__ , UpperCamelCase__ ) for day in days ): raise V...
283
0
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionMo...
268
"""simple docstring""" from __future__ import annotations class UpperCamelCase_ : def __init__( self : Any , lowerCAmelCase_ : int ) -> None: UpperCAmelCase_ : Any = data UpperCAmelCase_ : Node | None = None UpperCAmelCase_ ...
268
1
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclas...
61
'''simple docstring''' import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTe...
61
1
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, RandomS...
343
import inspect import unittest from transformers import BitConfig 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 BackboneTesterMixin from ...test_config...
343
1
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _A = logging.get_logger(__name__) class A ( lowerCamelCase__ ): def __init__( self, *UpperCamelCase__, **UpperCamelCase__ ): """simple do...
358
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is...
167
0
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import...
75
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def a__ ( snake_case , snake_case=False ): """simple docstring""" __SCREAMING_SNAKE_CASE : Dict = OmegaConf.load(snake_case ) if display: print(yaml.dump(Om...
303
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable A_ : List[Any] = {'configuration_gpt_neox': ['GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoXConfig']} try: if not is_tokenizers_av...
365
import argparse from collections import defaultdict def UpperCamelCase (lowercase_: List[str] , lowercase_: Optional[int] , lowercase_: Optional[Any] , lowercase_: Union[str, Any] , lowercase_: Any ) -> int: A__ : Optional[Any] = f"""{file}_{class_name}...
141
0
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import...
151
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils ...
115
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Dict = logging.get_logger(__name__) __snake_case :List[Any] = { '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': ( '''https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform...
368
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, r...
131
0
import qiskit def A ( lowercase = 2 ) -> qiskit.result.counts.Counts: '''simple docstring''' UpperCamelCase = qubits # Using Aer's simulator UpperCamelCase = qiskit.Aer.get_backend('aer_simulator' ) # Creating a Quantum Circuit acting on the q register UpperCamelCase = ...
222
from __future__ import annotations import os from collections.abc import Mapping _UpperCAmelCase : Tuple = tuple[int, int] class lowercase : def __init__( self , A_ , A_ ) -> None: """simple docstring""" UpperCamelCase = vertices UpperCamelCas...
222
1
"""simple docstring""" import re def lowercase ( a__ : str ) -> list: return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def lowercase ( a__ : str ) -> str: _UpperCamelCase = split_input(s...
54
"""simple docstring""" def lowercase ( a__ : Tuple , a__ : str ) -> Tuple: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase ( a__ : Optional[int] , a__ : List[str]=0 ) -> Optional[Any]: return ...
54
1
"""simple docstring""" import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_com...
60
from __future__ import annotations lowerCamelCase__ = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"""], } class...
302
0
import numpy # List of input, output pairs lowerCAmelCase__ = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) lowerCAmelCase__ = (((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9), 1_5_0)) lowerCAmelCase__ = [2, 4, 1, 5] lo...
356
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_deberta''': ['''DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DebertaConfig''', ...
121
0
from string import ascii_uppercase _SCREAMING_SNAKE_CASE = {str(ord(c) - 55): c for c in ascii_uppercase} def snake_case ( snake_case__ :int , snake_case__ :int) -> str: if isinstance(snake_case__ , snake_case__): raise TypeError("""int() can't...
180
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 ( AutoProcessor, B...
180
1
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup UpperCAmelCase__ = logging.get_logger(__name__) class __low...
290
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_ful...
290
1
UpperCAmelCase_ = [ 'Audio', 'Array2D', 'Array3D', 'Array4D', 'Array5D', 'ClassLabel', 'Features', 'Sequence', 'Value', 'Image', 'Translation', 'TranslationVariableLanguages', ] from .audio import Audio from .features import ArrayaD, ArrayaD, ArrayaD, ArrayaD...
12
"""simple docstring""" from scipy.stats import pearsonr import datasets __lowerCAmelCase : List[Any] =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calcula...
197
0
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCa...
169
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __snake_case = models.Sequential() # Step 1 - Convolutio...
169
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Union[str, Any] = logging.get_logger(__name__) _a : str = { 'bert-bas...
44
"""simple docstring""" from math import ceil def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Union[str, Any] ) -> int: _lowerCAmelCase : Dict = list(range(0 ,_lowerCamelCase ) ) _lowerCAmelCase : ...
44
1
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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_c...
365
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _UpperCAmelCase : Dict = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", "...
200
0
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutput, B...
270
import os def __magic_name__ ( ) -> str: __lowerCamelCase = os.path.join(os.path.dirname(__lowerCAmelCase ) , '''num.txt''' ) with open(__lowerCAmelCase ) as file_hand: return str(sum(int(__lowerCAmelCase ) for line in file_hand ) )[:10] if __n...
270
1
'''simple docstring''' def _lowerCamelCase ( lowerCamelCase_ : list[int] , lowerCamelCase_ : str ): """simple docstring""" UpperCAmelCase_ : Any = int(lowerCamelCase_ ) # Initialize Result UpperCAmelCase_ : Any =...
274
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class __SCREAMING_SNAKE_CASE ( lowerCamelCase_ , lowerCamelCase_ ): '''simp...
274
1
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def A ( lowercase , lowercase ) -> Any: '''simple docstring''' UpperCamelCase = args.log_output...
222
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def A ( lowercase ) -> Optional[Any]: '''simple docstring''' UpperCamelCase = [ 'encoder.version', 'decoder.version', 'model.encoder.versi...
222
1
'''simple docstring''' from __future__ import annotations from math import ceil, floor, sqrt def _a ( _lowercase : int = 2000000 ): '''simple docstring''' __UpperCAmelCase : list[int] = [0] __UpperCAmelCase : in...
240
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransfo...
240
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = ...
326
from __future__ import annotations from PIL import Image # Define glider example __lowercase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
43
0
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolForme...
95
"""simple docstring""" from __future__ import annotations import math def __UpperCAmelCase ( UpperCAmelCase_ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == ...
95
1
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase_...
104
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
177
0
def lowerCamelCase_ ( UpperCamelCase__ : str ) -> str: """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
348
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
348
1
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset...
16
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __a : int = logging.get_logger(__name__) __a : str = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.json""", } class _UpperCamelCa...
210
0
'''simple docstring''' import csv import tweepy # Twitter API credentials __snake_case : Union[str, Any] = '' __snake_case : Any = '' __snake_case : int = '' __snake_case : int = '' def _UpperCAmelCase ( _UpperCamelCase ...
367
'''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 # # U...
18
0
def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): __UpperCamelCase :int = f"""Input value of [number={number}] must be an integer""" raise TypeError(snake_case__ ) if number < 0: return False ...
43
"""simple docstring""" class lowerCAmelCase_ : '''simple docstring''' def __init__( self : int ,A_ : int ) -> Union[str, Any]: A = n A = [None] * self.n A = 0 # index of the first element A = ...
74
0
"""simple docstring""" from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __snake_case ( ) -> Any: '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase : List[Any] = 9, 14 # noqa: F841 ...
202
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, ...
202
1
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_sing...
58
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Dict = n - k # Calculat...
246
0
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE ( __UpperCamelCase : int , __UpperCamelCase : Dict , __UpperCamelCase : Optional[Any]=None , **__UpperCamelCase : Dict ) -> Optional[int]: Upper...
177
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Union[str, Any] , __UpperCamelCase : int , __UpperCamelCase : Union[str, Any] , __UpperCamelCase : List[str]=5 ) ...
177
1