code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import sys from collections import defaultdict class _A : def __init__( self : List[Any] ) -> Optional[int]: """simple docstring""" __snake_case : Optional[Any] = [] def lowercase__ ( ...
26
'''simple docstring''' def _a ( _lowerCamelCase ) -> int: """simple docstring""" if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("""only integers accepted as input""" ) else: __snake_case : List[Any] ...
26
1
"""simple docstring""" import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class snake_case (...
401
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class snake_case : def __init__( self :Dict , _lowerCamelCase :List[str] ): __SCREAMING_SNAKE_CASE : Union[str, Any] = str(id_ ) __SCREAMING_SNAKE_CAS...
401
1
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository c...
219
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, requ...
219
1
'''simple docstring''' def __lowerCamelCase ( _UpperCamelCase : int ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): UpperCAmelCase_ = F"""Input value of [number={number}] must be an integer""" raise TypeE...
43
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( _UpperCamelCase : tuple[int, int] , _UpperCamelCase : int ): '''simple docstring''' UpperCAmelCase_ , UpperCAmelCase_ = position UpperCAmelCase_ = [ ...
43
1
def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : Tuple = set() # edges = list of graph's edges __magic_name__ : List[str] = get_edges(_A ) # While there are still elements in edges list, take an arbitrary edge ...
324
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging __magic_name__: Dict = logging.ge...
324
1
'''simple docstring''' import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precis...
178
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: int ): if number > 0: raise ValueError("""input must be a negative integer""" ) __SCREAMING_SNAKE_CASE : str = len(bin(_lowerCamelCase )[3:] ) __SCREAMING_SNAKE_CASE : Any = bin(abs(_lowerCamel...
178
1
def _UpperCamelCase ( lowerCAmelCase_ = 1_0_0_0_0_0_0 ) ->int: UpperCAmelCase = set(range(3 , lowerCAmelCase_ , 2 ) ) primes.add(2 ) for p in range(3 , lowerCAmelCase_ , 2 ): if p not in primes: continue primes.difference_update(set(range(p * p...
377
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class __low...
377
1
'''simple docstring''' import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from f...
721
'''simple docstring''' __lowerCamelCase = range(2, 20 + 1) __lowerCamelCase = [10**k for k in range(ks[-1] + 1)] __lowerCamelCase = {} def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__ ) -> Tuple...
667
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase ...
403
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class lowercase ( a ): def __init__( self : Dict , _UpperCamelCase : Optional[int] , _UpperCamelCase : Any , _Upp...
403
1
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowerCamelCase_ : Union[str, Any] = 2_00 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that genera...
670
from manim import * class _UpperCamelCase ( _A ): '''simple docstring''' def lowerCAmelCase__ ( self : int ): UpperCamelCase_: Dict = Rectangle(height=0.5 , width=0.5 ) UpperCamelCase_: Dict = Rectangle(height=0.46 ,...
670
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available A_ : Optional[Any] ={"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is...
483
# 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 require...
483
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, 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_te...
721
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _a ( unittest.TestCase ): """simple docstring""" ...
26
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
437
"""simple docstring""" def UpperCAmelCase_ ( __a : int ): '''simple docstring''' _lowerCamelCase : Optional[Any] = int(__a ) if decimal in (0, 1): # Exit cases for the recursion return str(__a ) _lowerCamelCase , _lowerCame...
437
1
"""simple docstring""" import math class __A : def lowerCamelCase__ ( self : str , __snake_case : list[list[float]] , __snake_case : list[int] ) -> int: __magic_name__: Dict = 0.0 __magic_name__: ...
720
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, requ...
213
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __a ( SCREAMING_SNAKE_C...
228
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import C...
352
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _A : List[Any] = logging.get_logger(...
721
"""simple docstring""" import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() _A : Optional[Any] = logg...
518
0
'''simple docstring''' 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_commo...
50
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def A_ ( lowercase_ , lowercase_ , lowercase_ ) -> Dict: # Initialise PyTorch model _snake_...
326
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class __SCREAMING_SNAKE_CASE ( __a): @staticmethod @abstractmethod def UpperCamelCase__ ( _UpperCamelCase ): """simple docstring""" raise NotImplementedError() ...
706
from collections import deque from .hash_table import HashTable class __SCREAMING_SNAKE_CASE ( __lowercase): def __init__( self , *_UpperCamelCase , **_UpperCamelCase ): """simple docstring""" super().__init__(*_UpperCamelCase , ...
365
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase ( UpperCAmelCas...
42
def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list: """simple docstring""" snake_case_ : Tuple = len(_UpperCamelCase ) snake_case_ : Union[str, Any] = [[0] * n for i in range(_Upp...
60
0
"""simple docstring""" 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.d...
721
"""simple docstring""" import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data im...
696
0
"""simple docstring""" lowercase__ :str = {str(digit): digit**5 for digit in range(1_0)} def lowerCamelCase_ ( UpperCAmelCase_ ) ->int: """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(UpperCAmelCase_ ) ) def ...
522
"""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....
522
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia a...
533
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowerCAmelCase : List[str] = HfApi() lowerCAmelCase : Tuple = {} # fmt: off lowerCAmelCase : List[str] = torch.tensor([...
533
1
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def __lowerCamelCase ( self ): ...
421
'''simple docstring''' from cva import destroyAllWindows, imread, imshow, waitKey def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Optional[Any] ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE_, SCREAMING_SNAKE_CASE_ : Optional[int] = img.shape[0], ...
421
1
from sklearn.metrics import matthews_corrcoef import datasets a : List[str] = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto accou...
704
'''simple docstring''' a : List[Any] = """Alexander Joslin""" import operator as op from .stack import Stack def __lowerCamelCase ( _lowercase ) -> int: UpperCAmelCase : Dict = {"""*""": op.mul, """/""": op.truediv, """+""": op.add, """-""": op.sub} ...
672
0
"""simple docstring""" from math import pow, sqrt def SCREAMING_SNAKE_CASE ( *snake_case): __snake_case = len(snake_case) > 0 and all(value > 0.0 for value in values) return result def SCREAMING_SNAKE_CASE ( snake_case, snake_case): return ( ...
564
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin __lowercase : str = get_test...
564
1
import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
708
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch lowerCAmelCase = """sshleifer/bart-tiny-random""" lowerCAme...
675
0
from __future__ import annotations import math def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : bool ,a__ : list[int] ,a__ : float ) -> int: if depth < 0: raise ValueError("""Depth cannot be less than 0""" ) if not scores: raise ValueEr...
17
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> Tuple: __A : List[Any] = ArgumentParser( description=( """PyTorch TPU distributed t...
17
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase_ : Any = {'''configuration_vit''': ['''VIT_PRETRAINED...
712
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
265
0
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase ) -> List[str]: '''simple docstring''' return " ".join( ''''''.join(word[::-1] ) if len(lowerCamelCase__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": ...
640
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging __lowerCAmelCase : int = logging.get_logger(__name__) # pylint: disable=invalid-name class ...
644
0
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_au...
706
"""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.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipelin...
439
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler,...
390
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ : Union[str, Any] = { 'configuration_table_transformer': [ 'TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TableTransf...
244
"""simple docstring""" def _snake_case ( lowerCamelCase__ : Dict ) -> Dict: lowerCamelCase_ : Dict =[0] * len(lowerCamelCase__ ) lowerCamelCase_ : Tuple =[] lowerCamelCase_ : Optional[int] =[1] * len(lowerCamelCase_...
244
1
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transf...
545
"""simple docstring""" import argparse import copy def A ( __snake_case: Union[str, Any] ) -> Tuple: """simple docstring""" __magic_name__ = {} with open(__snake_case ) as f: for line in f: i...
545
1
"""simple docstring""" a_ = frozenset( [ "prompt", "height", "width", "guidance_scale", "negative_prompt", "prompt_embeds", "negative_prompt_embeds", "cross_attention_kwargs", ] ) a_ = frozen...
621
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
621
1
from maths.prime_check import is_prime def _UpperCAmelCase ( UpperCamelCase: int ): """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): __lowerCAmelCase = F"Input value of [number={number}] must be an integer" raise TypeError(UpperCamelCase ) if is_pri...
611
class a : def __init__( self : Union[str, Any] , snake_case__ : str ): """simple docstring""" __lowerCAmelCase = arr.split("," ) def UpperCAmelCase__ ( self : str ): """simple docstring""" __lowerCAmelCase ...
611
1
"""simple docstring""" import requests __lowerCAmelCase : Optional[int] = '''https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=''' def __lowerCAmelCase ( __UpperCamelCase : str ): '''simple docstring''' s...
714
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : bool = False ): '''simple docstring''' if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n ...
21
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...
671
from __future__ import annotations from math import ceil, floor, sqrt def A_ ( _UpperCAmelCase = 2_00_00_00 ): SCREAMING_SNAKE_CASE_: list[int] = [0] SCREAMING_SNAKE_CASE_: int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ...
671
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers...
708
"""simple docstring""" import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <us...
463
0
def a__ ( lowercase__ = 1 , lowercase__ = 1_0_0_0 ): '''simple docstring''' UpperCAmelCase_ =1 UpperCAmelCase_ =0 for divide_by_number in range(lowercase__ , digit + 1 ): UpperCAmelCase_ =[] UpperCAmel...
54
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def a__ ( lowercase__ , lowercase__ , lowercase__=1_0_2_4 , lowercase__=1_0_2_4 , lowercase__=False , ...
54
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __magic_name__ = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwiftFormerConfig""", """S...
720
def UpperCAmelCase__( __UpperCAmelCase : str ): if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) __snake_case : str = sorted(string.lower() ) return len(__UpperCAmelCase ) == len(set(__UpperCAmelCa...
679
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ : Union[str, Any] = { """configuration_xlm_roberta_xl""": [ """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMRobert...
33
'''simple docstring''' from itertools import permutations def UpperCAmelCase_ ( __lowerCamelCase : tuple ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False lowercase_ :...
172
0
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(): from PIL import Image from ..image...
380
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) lowercase_ = {'configuration_beit': ['BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BeitConfig', 'BeitOnnxConfi...
380
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : list[list[str]] = [[] for _ in range(UpperCamelCase )] lowerCAmelCase__ : List[str] = key - 1 if key <= 0: ...
565
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _lowerCAmelCase = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = "mumbai" ): ""...
565
1
'''simple docstring''' import cmath import math def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase ) -> complex: '''simple docstring''' snake_case_ = math.radians(__UpperCAmelCase ) snake_case_ = math.radians(_...
718
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated a : int = collections.namedtuple('_...
593
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """edbeeching/decision-transformer-gym-hopper-medium""": ( """https://huggingface.co/edbeeching/dec...
82
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowercase__( A ): snake_case__ : List[Any] = {} snake_case__ : int = tokenizer(exa...
170
0
'''simple docstring''' from collections import Counter from timeit import timeit def _lowerCAmelCase( UpperCAmelCase_ : str = "" , ) -> Tuple: return sum(c % 2 for c in Counter(input_str.replace(""" """ , """""" ).lower() ).values() ) < 2 def _lowerCAmelCase( ...
718
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ...
211
0
"""simple docstring""" import functools def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> int: lowercase__: Any = len(__UpperCAmelCase ) lowercase__: Any = len(__UpperCAmelCase ) @functools.cache def min_distance(__UpperCAmelCase , _...
586
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "distilbert-base-uncased": "https://huggingfa...
586
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
543
'''simple docstring''' import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from t...
543
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase_ ) class _SCREAMING_SNAKE_CASE ( UpperCAmelCase_ ): lowerCAmelCase__ = field(default='question-answering-extra...
463
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging lowerCAmelCase_ = logging.get_logger(__name__) class _lowerCAmelCase ( UpperCAmelCase_ ): '''simple ...
411
0
"""simple docstring""" import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() UpperCAmelCase = [ '''word_embedd...
712
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
475
0
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils i...
515
from ..utils import DummyObject, requires_backends class a__ ( metaclass=UpperCamelCase__ ): a : int = ["""torch""", """scipy"""] def __init__( self , *A , **A ) -> str: '''simple docstring''' requires_b...
515
1
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.utils im...
718
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets lowercase_ : List[str] = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "Snover, Matthew and D...
652
0
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 __a = datasets.utils.logging.get_logger(...
97
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_a...
56
0
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _lowercase ( lowercase__ , lowercase__ , lowercase__ , lowercase__ ): __lowerCAmelCase : List[str] = { '''en''': '''Machine learning is great, isn\'t it?''', '''ru'''...
583
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available(): raise ...
583
1
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): # encoder.embeddings are double copied in original FLAVA return sum...
669
import math def UpperCamelCase__( UpperCamelCase__ : int )->list: A__ = [True] * n A__ = False A__ = False A__ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): A__ = i * 2 wh...
190
0
import collections import importlib.util import os import re from pathlib import Path lowerCAmelCase_ = 'src/transformers' # Matches is_xxx_available() lowerCAmelCase_ = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} lowerCAmelCase_ = re.com...
110
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_albert im...
110
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { "facebook/xlm-roberta-xl": "h...
666
from collections.abc import Sequence def lowerCAmelCase_ ( lowerCamelCase = None ): if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) __magic_name__ : str =nums[0] for i in range(1 , len(lowerCamelCase ) ...
21
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase__ :Optional[Any] = { """configuration_resnet""": ["""RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", ""...
704
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list ...
483
0
"""simple docstring""" 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, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils...
129
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
129
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( A : Optional[Any] , A : Any ) -> Any: """simple docstring""" while second != 0: __snake_case : List[Any] = first & second first ^= second ...
713
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( A : list ) -> list: """simple docstring""" __snake_case : Tuple = False while is_sorted is False: # Until all the indices are traversed keep looping __snake_case : ...
61
0
from collections.abc import Callable class UpperCamelCase_ : '''simple docstring''' def __init__( self , UpperCamelCase = None) -> Union[str, Any]: UpperCamelCase__ : Optional[Any] = [] # Stores indexes of each item for supporting updates an...
410
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'tokenization_tr...
603
0
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder lowerCamelCase_ : Tuple = """__DUMMY_TRANSFORMERS_USER__""" lowerCamelCase_ : List[Any] = """Dummy User""" lowerCamelCase_ : Op...
670
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
670
1
from __future__ import annotations import os from collections.abc import Mapping UpperCamelCase__ = tuple[int, int] class A : def __init__(self : Any , __UpperCAmelCase : set[int] , __UpperCAmelCase : Mapping[EdgeT, int] ) -> None: """simple d...
486
from random import shuffle import tensorflow as tf from numpy import array def _a ( SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : int ) -> Optional[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] ...
663
0
"""simple docstring""" import numpy as np class _UpperCAmelCase : """simple docstring""" def __init__( self , _lowercase=None , _lowercase=None , _lowercase=None , _lowercase=None , _lowercase=None ) -> Union[str, Any]: self.set_matricies(red=_...
719
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str =logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : List[Any] ={ 'asapp/sew-d-tiny-100k': 'https://huggingfa...
558
0
'''simple docstring''' import math def _SCREAMING_SNAKE_CASE ( __snake_case : int ): _A = [] _A = 2 _A = int(math.sqrt(__snake_case ) ) # Size of every segment _A = [True] * (end + 1) _A = [] while start <= end: i...
107
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCAmelCase : str = { '''configuration_vision_encoder_decoder''': ['''VisionEnco...
107
1
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require_s...
711
def UpperCAmelCase ( UpperCamelCase__ = 10_00 ) -> int: '''simple docstring''' __lowerCAmelCase = -1 __lowerCAmelCase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c __lowe...
334
0
_lowercase = range(2, 20 + 1) _lowercase = [10**k for k in range(ks[-1] + 1)] _lowercase = {} def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__): lowerCAmelCase_ : str = sum(a_i[j] for j in range(snake_case__ , ...
659
"""simple docstring""" def lowercase__(A ) ->bool: """simple docstring""" return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def lowercase__(A ) ->bool: """simple docstring""" lowerca...
218
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 ( AutoTok...
705
from __future__ import annotations import collections import pprint from pathlib import Path def UpperCAmelCase ( lowerCAmelCase__ ): '''simple docstring''' return "".join(sorted(lowerCAmelCase__ ) ) def UpperCAmelCase ( lowerCAmelCase__ ): '''simple d...
205
0
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ): """s...
327
def UpperCAmelCase_ (_lowerCAmelCase : int = 60_08_51_47_51_43 ): try: __UpperCamelCase : Optional[Any] = int(_lowerCAmelCase ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter...
327
1
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def _lowerCAmelCase ( lowercase : int , lowercase : Any=1 ) ->Any: """simple docstring""" if ...
720
'''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...
318
0
from __future__ import annotations from collections.abc import Iterator from typing import Any class __magic_name__ : """simple docstring""" def __init__( self : Tuple , _lowercase : Tuple ): """simple docstring""" _UpperCamelCase: Any = data _Up...
271
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(_SCREAMING_SNAKE_CASE ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod ...
93
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ :Any = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig"""...
720
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ ...
374
0
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : str ): A__ = [int(_lowerCamelCase ) for i in ip_va_address.split("." ) if i.isdigit()] return len(_lowerCamelCase ) == 4 and all(0 <= int(_lowerCamelCase ) <= 2_54 for octet in octets ) if __name__ == "__...
440
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
440
1
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_M...
345
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, BlipaProcessor, BlipImageProcessor, GPTa...
345
1
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = '▁' _lowerCamel...
144
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _lowerCamelCase = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.self', 'self.pro...
144
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : str = logging.get_logger(__name__) _UpperCAmelCase : List[str] = { """microsoft/cvt-13""": """https://huggingface.co/microsoft/cvt-13/resolve/main/config.json""", # See all Cvt models ...
702
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_to...
108
0
"""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, BertConfig, BertTokenizer, ...
160
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor A: Tuple = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( UpperCAmelCase__ ): def __init__( self , *_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CA...
160
1
'''simple docstring''' from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def SCREAMING_SNAKE_CASE__ ( __A = "laptop" ) -> Optional[int]: _snake_case = F'https://www.amazon.in/laptop/s?k={product}' _snake_case = {...
713
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Model...
542
0
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 lowerCAmelCase = logging.get_logger(__name__) ...
230
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import T...
230
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
569
import numpy as np def __lowerCamelCase ( snake_case__ ) -> np.array: """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
569
1
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, BertConfig, BertTokenizer, BertTokenizerFast, CTRL...
321
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case : """simple docstring""" __lowerCAmelCase = 42 __lowerCAmelCase = None __lowerCAmelCase = None lowerCAmelCase__ =...
321
1
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension ...
711
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def lowerCamelCase ( UpperCAmelCase__ : int , UpperCAmelCase__ : int , UpperCAmelCase__ : float = 1 / sqrt(2 ) ) -> IIRFilter: lowercase_ : str ...
30
0
from collections import deque from .hash_table import HashTable class __a( _a ): """simple docstring""" def __init__( self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE ) -> List[Any]: super().__init__(*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE ) ...
30
def lowerCamelCase__ ( ): '''simple docstring''' UpperCAmelCase_ : Dict = 0 for i in range(1 , 1001 ): total += i**i return str(_lowercase )[-10:] if __name__ == "__main__": print(solution())
30
1
"""simple docstring""" import math def _lowerCAmelCase ( lowerCamelCase__ : str, lowerCamelCase__ : str ) -> Union[str, Any]: '''simple docstring''' if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. r...
703
"""simple docstring""" from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax ...
295
0
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # al...
128
'''simple docstring''' from math import factorial def lowerCAmelCase__ ( lowerCamelCase : int ,lowerCamelCase : int ,lowerCamelCase : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or ...
128
1
from __future__ import annotations import os from collections.abc import Mapping SCREAMING_SNAKE_CASE__ = tuple[int, int] class __lowerCAmelCase : """simple docstring""" def __init__( self : Optional[int] , _snake_case : set[int] , _snake...
721
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_configuration_common import Conf...
52
0
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @requir...
53
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __magic_name__ = TypeVar('''T''') class _SCREAMING_SNAKE_CASE ( Generic[T] ): def __init__( self , lowerCamelCase ): snake_case__ = data sna...
276
0
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 .tokenization_blenderbot imp...
703
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from t...
499
0
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_availa...
128
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def lowerCAmelCase__ ( lowerCamelCase : Callable[[int | float], int | float] ,lowerCamelCase : int | float ,lowerCamelCase : int | float ,lowerCamelCase : int = 100 ,): ...
128
1
'''simple docstring''' import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput lowercase__ =logging.getLogger(__name__) if is_torch_tpu_available...
511
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import ...
511
1
'''simple docstring''' from __future__ import annotations def __snake_case (__UpperCAmelCase , __UpperCAmelCase ): """simple docstring""" # Checks if the entire collection has been sorted if len(__UpperCAmelCase ) <= 1 or n <= 1: return insert_next(__UpperCAmelCase ...
501
'''simple docstring''' 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 __lowerCamelCase...
501
1
__UpperCamelCase : Optional[Any] = { 'Pillow': 'Pillow', 'accelerate': 'accelerate>=0.11.0', 'compel': 'compel==0.1.8', 'black': 'black~=23.1', 'datasets': 'datasets', 'filelock': 'filelock', 'flax': 'flax>=0.4.1', 'hf-doc-builder': 'hf-doc-builder>=0.3....
641
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : str = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', '...
641
1
"""simple docstring""" import os def __A ( ) -> Tuple: with open(os.path.dirname(a_) + '''/grid.txt''') as f: __a : Dict = [] # noqa: E741 for _ in range(20): l.append([int(a_) for x in f.readline().split()]) __a ...
52
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common imp...
397
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration __A : str = 5_0_0_0_0 __A : Optional[Any] = 5_0_0_0 __A : Union[str, Any] = os.path.split(__file__) __A : int = os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.re...
718
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, BertTokenizer, Bl...
698
0
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer else: a...
35
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCamelCase ( a ): """simple docstring""" UpperCAmelCase_ : Dict ="ClapFeatureExtractor" UpperCAmelCase_ : Union[str, Any] =("RobertaToken...
243
0
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets UpperCAmelCase : Tuple = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. Fo...
712
"""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, ) UpperCAmelCase : Any = {...
100
0
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : """simple docstring""" def __init__( self , _snake_case , _snake_case ) -> Optional[Any]: _UpperCamelCase, _UpperCamelCase : int = text, pattern _UpperCamelCase, ...
683
'''simple docstring''' # Copyright 2022 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 # # Unl...
683
1
def A ( _lowercase ): if n_term == "": return [] SCREAMING_SNAKE_CASE : Optional[int] = [] for temp in range(int(_UpperCamelCase ) ): series.append(f"""1/{temp + 1}""" if series else '''1''' ) return series if __name__ == "__...
715
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer e...
34
0
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowercase__ : Dict = log...
8
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_i...
585
0
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.c...
242
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 import is_torc...
242
1