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
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
85
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer UpperCAmelCase =logging.get_logge...
617
0
from collections import defaultdict class __snake_case : """simple docstring""" def __init__( self : Tuple ,lowerCAmelCase__ : Tuple ,lowerCAmelCase__ : List[Any] ) -> Optional[int]: '''simple docstring''' lowerCAmelCase_ : List...
683
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils impor...
683
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''shi-labs/dinat-mini-...
684
import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
493
0
import math def __magic_name__ ( lowercase_ , lowercase_ ) -> float: '''simple docstring''' if initial_intensity < 0: raise ValueError("The value of intensity cannot be negative" ) # handling of negative values of initial intensity ...
414
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __a : Union[str, Any] = logging.get_logger(__name__) def __magic_name__ ( lowercase_ ) -> ...
414
1
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class A_ ( __UpperCAmelCase ): '''simple docstring''' ...
138
"""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/L...
567
0
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase : def __init__( self , lowercase__): __UpperCAmelCase : List[str] = str(id_) __UpperCAmelCase : str = None __UpperCAmelCase : Any = ...
720
from typing import TYPE_CHECKING from ....utils import _LazyModule lowerCAmelCase = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys lowerCAmelCase = _LazyModule(__name__, globals()["""__file...
675
0
"""simple docstring""" import argparse A_ = """docs/source/_static/js/custom.js""" def lowercase ( lowerCAmelCase__ ): with open(lowerCAmelCase__ ,encoding='''utf-8''' ,newline='''\n''' ) as f: lowerCamelCase_ = f.readlines() lowerCamelCase_ = 0 # First...
29
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Tuple = logging.get_logger(__name__) UpperCAmelCase : List[str] = { "asapp/sew-tiny-100k": "https://huggingface.co/as...
567
0
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class snake_case_ ( __A , unittest.TestCase ): ...
253
class snake_case_ : '''simple docstring''' def __init__( self : str ) -> Optional[int]: lowerCamelCase_ : Optional[Any] = "" lowerCamelCase_ : Dict = "" lowerCamelCase_ : Union[str, Any] = [] ...
253
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Di...
35
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFM...
351
0
UpperCAmelCase_ : str = [ """Audio""", """Array2D""", """Array3D""", """Array4D""", """Array5D""", """ClassLabel""", """Features""", """Sequence""", """Value""", """Image""", """Translation""", """TranslationVariableLanguages""", ] from .audio impo...
706
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 from ...tokenization_ut...
440
0
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.uti...
513
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNewToke...
513
1
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate UpperCAmelCase_ : Tuple = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow(...
712
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel UpperCAmelCase_ : Optional[int] = { "text_branch": "text_model", "audio_branch": "audio_model.audio_encoder", "attn": "attention...
367
0
'''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_modelin...
267
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Dict = 1 __lowerCamelCase : str = 2 while i * i <= n: __lowerCamelCase : int = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: ...
669
0
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): impo...
392
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torc...
392
1
'''simple docstring''' def snake_case_ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): """simple docstring""" return price * (1 + tax_rate) if __name__ == "__main__": print(F"{price_plus_tax(100, 0.25) = }") print(F"{price_plus_tax(125.50, 0.05) = }")
533
'''simple docstring''' 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_ba...
533
1
import math from collections.abc import Callable def __snake_case ( _UpperCAmelCase : List[str], _UpperCAmelCase : str, _UpperCAmelCase : Tuple): UpperCamelCase = xa UpperCamelCase = xa while True: if x_n == x_na or function(_Upp...
719
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils impo...
350
0
"""simple docstring""" import datasets from .evaluate import evaluate __lowerCAmelCase : Tuple = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Che...
58
"""simple docstring""" import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
589
0
"""simple docstring""" import random from typing import Any def lowercase__ ( snake_case_ :list ): for _ in range(len(snake_case_ ) ): __UpperCAmelCase = random.randint(0 , len(snake_case_ ) - 1 ) __UpperCAmelCase = random.randint(0 , l...
720
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_tes...
397
0
"""simple docstring""" import mpmath # for roots of unity import numpy as np class lowercase__ : def __init__( self , SCREAMING_SNAKE_CASE=None , SCREAMING_SNAKE_CASE=None) -> Tuple: # Input as list _lowerCamelCase : Any = list(poly_a or [0]...
88
"""simple docstring""" from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCAmelCase = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation...
88
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'facebook/convnextv2-tiny-1k-224': 'htt...
371
import re import string import numpy as np import datasets _UpperCAmelCase = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' _UpperCAmelCase = '\nArgs:\n predictions: List of p...
371
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __magic_name__ ={ '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConfig...
415
import os import jsonlines import numpy as np from tqdm import tqdm __magic_name__ =2048 __magic_name__ =4096 __magic_name__ =42 __magic_name__ =os.environ.pop('''PROCESS_TRAIN''', '''false''') __magic_name__ ={'''null''': 0, '''short''': 1, '''long''': 2, '''yes''': 3, '''no''': ...
415
1
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _a ( __UpperCamelCase ): a_ : int = int(number**0.5 ) return number == sq * sq def _a ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ...
478
from heapq import heappop, heappush import numpy as np def _a ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , ): a_ , a_ : Any = grid.shape a_ : Dict = [-1, 1, 0, 0] a_ : List[Any] = [0, 0, -...
478
1
from __future__ import annotations from collections.abc import Sequence from typing import Literal def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = list(SCREAMING_SNAKE_CASE ) lowercase__ = list(SCREAMING_SNAKE_CASE ) l...
43
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channe...
599
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_...
244
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIP...
244
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CLIPSegVisionConfig", ], "pro...
393
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 import IterableDataset from...
488
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCamelCase = logging.get_logger(__name__) _UpperCa...
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 enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger __UpperCAmelCase : Optional[Any] = get_logger(__name__) class _snake_case ( enum.Enum ): _A = 'all_checks' _A =...
241
from __future__ import annotations def lowercase_ ( __snake_case : list[int] ) -> int: '''simple docstring''' if not nums: return 0 snake_case__ :Union[str, Any] = nums[0] snake_case__ :List[Any] = 0 for num i...
241
1
'''simple docstring''' import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax...
700
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets A_ = "\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Models f...
384
0
from __future__ import annotations snake_case : Optional[int] = [] def lowerCAmelCase_ ( _snake_case : list[list[int]] , _snake_case : int , _snake_case : int ) -> bool: '''simple docstring''' for i in range(len(_snake_case ) ): if board[row][i] == 1:...
124
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMScheduler...
124
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
378
"""simple docstring""" import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import ...
378
1
"""simple docstring""" import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinCo...
49
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_torchau...
519
0
def __lowerCAmelCase ( snake_case : list[int] ) -> list[list[int]]: __lowerCamelCase: Optional[Any] = [] if len(snake_case ) == 1: return [nums.copy()] for _ in range(len(snake_case ) ): __lowerCamelCase: Tuple = nums.pop(0 ) __lowerCamelCase: ...
189
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_configuration_common import ConfigTester from ...test_mod...
189
1
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union lowerCAmelCase_ = TypeVar('T') lowerCAmelCase_ = Union[List[T], Tuple[T, ...]] lowerCAmelCase_ = Union[T, List[T], Dict[str, T]] lowerCAmelCase_ = Union[str, bytes, os.PathLike]
560
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __A : '''simple docstring''' lowerCAmelCase : int lowerCAmelCase : TreeNode | None = ...
560
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
703
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer a_ = logging.get_logger(__name__) a_...
665
0
"""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 # #...
4
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowercase : """simple docstring""" def __init__( self : Union[str, Any] , lowerCamelCase_ : Optional[int]=2 ...
304
0
from queue import PriorityQueue from typing import Any import numpy as np def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_...
311
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase__: List[str] = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]...
311
1
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase_ (__A ): __magic_...
95
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE : Any , SCREA...
179
0
def _A( UpperCamelCase__ : Dict ) -> int: '''simple docstring''' if not isinstance(__UpperCamelCase , __UpperCamelCase ): raise TypeError('''only integers accepted as input''' ) else: __lowercase = str(abs(__UpperCamelCase ...
708
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logging...
362
0
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def A ( snake_case__ , snake_case__ , snake_case__=10_24 , snake_case__=10_24 , sna...
196
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo __lowercase : Optional[int] ="""\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, ...
54
0
from __future__ import annotations from collections.abc import Callable _lowerCamelCase : Optional[Any] = list[list[float | int]] def A__ ( __A : Optional[Any] , __A : Optional[Any] ) ->Matrix: __A =len(SCREAMING_SNAKE_CASE_ ) __A =[[0 for _ in r...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : int = logging.get_logger(__name__) _lowerCamelCase : List[str] = { '''microsoft/biogpt''': '''https://huggingface.co/microsoft/biogpt/resolve/main/config.json''', # See all Bio...
516
0
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import Thr...
289
'''simple docstring''' from __future__ import annotations def _lowercase ( lowerCamelCase__ ) -> float: """simple docstring""" __UpperCAmelCase : Any = 0.00 __UpperCAmelCase : Union[str, Any] = 0 for resistor...
168
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor _UpperCamelCase : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase_ ( _a): def __init__( self , *a , **a ...
709
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
645
0
from ..utils import DummyObject, requires_backends class lowercase ( metaclass=snake_case__): """simple docstring""" a__ : Tuple = ["note_seq"] def __init__( self : Union[str, Any] , *__UpperCAmelCase : List[str] , **__UpperCAmelCase : List[...
593
def __lowerCAmelCase ( __lowerCamelCase : int ) -> bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
354
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMIN...
104
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]} try: if not is_torch_available(): raise...
104
1
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ...
39
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
0
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import Tokeniz...
702
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ...
66
0
import os def lowerCAmelCase__ ( ): with open(os.path.dirname(_a ) + "/grid.txt" ) as f: snake_case_ : Any = [] # noqa: E741 for _ in range(20 ): l.append([int(_a ) for x in f.readline().split()] ) snake_case_ : Union[str, Any] ...
568
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : List[Any] = logging.get_logger(__name__) lowercase : str = { '''vocab_file''': '''vocab.txt''',...
568
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorType...
664
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxConfig"]} try:...
664
1
from statistics import mean, stdev def __a ( lowerCAmelCase_ : list ,lowerCAmelCase_ : int = 3 ) -> list: '''simple docstring''' UpperCAmelCase_= min(lowerCAmelCase_ ) UpperCAmelCase_= max(lowerCAmelCase_ ) # normalize data return ...
593
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int , lowerCAmelCase: int ) -> Dict: if b == 0: return 1 if (b % 2) == 0: return actual_power(lowerCAmelCase , int(b / 2 ) ) * actual_power(lowerCAmelCase , int(b / 2 ) ) else: return a * actual_power(low...
300
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): import torch_xla.core.xla_...
54
import operator def lowerCAmelCase_ ( snake_case_,snake_case_ = False,snake_case_ = None ): _A : str = operator.lt if reverse else operator.gt _A : Optional[Any] = solution or [] if not arr: return solution _A : Dict = [arr.po...
54
1
import numpy as np def UpperCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ = 1E-12 , snake_case__ = 100 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(snake_case__ )[0] == np.shape(snake_case__ )[1] # Ensure proper...
193
from bisect import bisect from itertools import accumulate def UpperCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ ) -> Optional[int]: """simple docstring""" lowerCAmelCase__ = sorted(zip(snake_case__ , snake_case__ ) , ...
193
1
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch SCREAMING_SNAKE_CASE_ ...
719
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class a ( UpperCAmelCase ): def __init__( self , *A_ , **A_ ): '''simple docstring'...
467
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( __snake_case : int = 4_0_0_0_0_0_0 ): _A = [] _A , _A = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__snake_case ) _A , _A = b, a + b return sum(__s...
107
from __future__ import annotations import requests UpperCamelCase_ = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories c...
625
0
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def A_ ( UpperCAmelCase__ , UpperCAmelCase__=False ) -> List[str]: a : Tuple = OmegaConf.load(UpperCAmelCase__ )...
509
"""simple docstring""" from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord ...
509
1
"""simple docstring""" import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCa...
104
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__na...
104
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diff...
558
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelCase (...
558
1
"""simple docstring""" # Lint as: python3 import itertools import os import re a_ = re.compile(r"""([A-Z]+)([A-Z][a-z])""") a_ = re.compile(r"""([a-z\d])([A-Z])""") a_ = re.compile(r"""(?<!_)_(?!_)""") a_ = re.compile(r"""(_{2,})""") a_ = r"""^\w+(\.\w+)*$""" ...
437
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor a_ = logging.get_logger(__name__) class A_(SCREAMING_SNAKE_CASE_ ): """simple docstring""" def __init__( self , *A , **A ...
437
1
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_...
712
"""simple docstring""" 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 ...
282
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Any ): """simple docstri...
419
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.uti...
189
0
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def a_ ( lowerCamelCase : Tuple ): lowerCAmelCase = [ 'decoder.version', 'decoder.out...
513
'''simple docstring''' import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput __snake_case ="""scheduler_config.json""" class UpperCAmelCase_ ( __lowercase...
513
1
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCAmelCase__ ( __snake_case ) -> Any: # A local function to see if a dot lands in the circle. def is_in_circle(__snake_case , __snake_case ) -> bool: _A...
317
from __future__ import annotations def UpperCAmelCase__ ( __snake_case , __snake_case ) -> bool: _A = get_failure_array(__snake_case ) # 2) Step through text searching for pattern _A , _A = 0, 0 # index into text, pattern while i < len(__snake...
317
1
from collections.abc import Sequence from queue import Queue class _lowerCamelCase: def __init__( self, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase=None, lowerCamelCase=None) -> Union[str, Any]: """simple docstring""" _lowercase : Li...
711
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_configuration_common import ConfigTester from ...test_mod...
354
0
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a = logging.get_logger(__name__) class lowercase_ ( __lowerCAmelCase ): '''simple docstring''...
7
"""simple docstring""" class lowercase_ : '''simple docstring''' def __init__( self : List[Any] , _UpperCAmelCase : Optional[Any] , _UpperCAmelCase : int , _UpperCAmelCase : int ): _A = None _A = None _A = graph...
7
1
def snake_case__ ( _snake_case : list ): """simple docstring""" if len(UpperCamelCase__ ) <= 1: return [tuple(UpperCamelCase__ )] UpperCamelCase__ = [] def generate(_snake_case : int , _snake_case : list ): ...
720
"""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 ...
304
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPE...
593
'''simple docstring''' import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from ...
446
0
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git imp...
721
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from ...
317
0
import os def UpperCamelCase ( ) -> Dict: '''simple docstring''' lowercase_ :int = os.path.dirname(os.path.realpath(_a ) ) lowercase_ :Any = os.path.join(_a , '''triangle.txt''' ) with open(_a ) as f:...
257
import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer fr...
257
1
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class _lowerCAmelCase ( unittest.TestCase ): """simple docstring""...
408
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { ...
408
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging loggin...
343
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from datas...
343
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = {"vocab_file": "spiece.model"} ...
294
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class lowerCamelCase ( A_ ...
294
1
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """t5-small""": """https://huggingface.co/t5...
178
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMo...
178
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : List[Any] = { """configuration_blenderbot"...
706
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): '''simpl...
265
0
"""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/LICE...
34
from functools import reduce _A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452445231617318564030987111217223831...
290
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : int = { '''configuration_whisper''': ['''WHISPER_...
700
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accelerato...
357
0
'''simple docstring''' 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...
50
from __future__ import annotations from typing import Any class _A : def __init__( self : List[Any] , lowerCamelCase__ : int , lowerCamelCase__ : int , lowerCamelCase__ : float = 0 ): """simple docstring""" __UpperCamelCase , __UpperCamelCa...
269
0
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _a : str= datasets.load_iris() _a : List[Any]= np.array(data["data"]) _a : Optional[Any]= np.array(data["target"]) _a : ...
710
"""simple docstring""" import math def __UpperCAmelCase ( UpperCAmelCase_ : list , UpperCAmelCase_ : int ) -> int: '''simple docstring''' __snake_case : List[str] = len(UpperCAmelCase_ ) __snake_case : ...
192
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase = {'configuration_dpt': ['DPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DPTConfig']} try: if not i...
43
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { "facebook/deit-base-distilled-patch16-22...
475
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 __lowerCamelCase = logging.get_logger(__name_...
701
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAm...
667
0
'''simple docstring''' import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def _A ( A ,A ,A ,A=5 ) -> List[str]: # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_interface.py assert masked_input.count("<mask...
372
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _A ( A ) -> int: # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Uni...
372
1
def _a ( lowerCamelCase__ ) -> Optional[Any]: lowerCamelCase_ : List[str] = [] if len(lowerCamelCase__ ) == 1: return [nums.copy()] for _ in range(len(lowerCamelCase__ ) ): lowerCamelCase_ : List[str] = nums.pop(0 ) ...
702
import argparse import collections import json import os import re import string import sys import numpy as np UpperCamelCase = re.compile(r'''\b(a|an|the)\b''', re.UNICODE) UpperCamelCase = None def _a ( ) -> Tuple: lowerCamelCase_ : Optional[int] = ar...
144
0
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedu...
104
'''simple docstring''' from __future__ import annotations import time import numpy as np _UpperCAmelCase : int = [8, 5, 9, 7] _UpperCAmelCase : List[str] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] _UpperCAmelCase : Union[str, Any] = [ [3, 2, 1, 4...
72
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) lowercase__ :Optional[int] = 2_9979_2458 # Symbols lowercase__ , lowercase__ , lowercase__ , lowercase__ :Dict = symbols("ct x y z") def UpperCamelCase ( ...
633
import argparse from collections import defaultdict import yaml lowercase__ :Optional[int] = "docs/source/en/_toctree.yml" def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = defaultdict(lowerCAmelCase__ ) for doc in model_doc: counts[...
633
1
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 HeunDiscreteScheduler fro...
130
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import BitConfig...
130
1
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common import ...
561
from collections import defaultdict class a_ : def __init__( self :Tuple , _lowercase :List[str] , _lowercase :List[Any]) -> List[Any]: UpperCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N ...
561
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 mul...
250
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A__: str = logging.get_logger(__name__) A__: Union[str, Any] = { '''SenseTime/deformable-detr''': '''https://huggingface.co/sensetime/deformable-detr/res...
380
0
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np lowerCamelCase =typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 lowerCamelCase =typing.Union[np.floataa, int, float] # noqa: UP007 def SCREAMING_SNAKE_CASE_ ( U...
462
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase ={ "configuration_mobilebert": [ "MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MobileBertCon...
462
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowerCAmelCase : int = { "configurat...
261
'''simple docstring''' class snake_case : """simple docstring""" def __init__( self ) -> None: """simple docstring""" snake_case__ : dict[str, TrieNode] = {} # Mapping from char to TrieNode snake_case__ : int = False d...
261
1
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class __UpperCAmelCase : def __init__( self: str , UpperC...
569
import math from numpy import inf from scipy.integrate import quad def __lowerCamelCase ( snake_case__ ) -> float: """simple docstring""" if num <= 0: raise ValueError("""math domain error""" ) return quad(snake_case__ ,0 ,sna...
569
1
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_im...
387
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docst...
387
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a_ = { "configuration_roc_bert": ["ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RoCBertConfig"], "tokenization_roc_bert": ["RoCBer...
92
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME a_ = ["small", "medium", "large"] a_ = "lm_head.decoder.weight" a_ = "lm_head.weight" def UpperCamelCase_ ( __SCREAMING_SNAKE_CASE, __SCREAMING_SNAKE_C...
92
1
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase__ : Tuple = logging.get_logger(__name__) UpperCAmelCase__ : List[str] = { "google/umt5-small...
48
import math def UpperCamelCase ( _A, _A ): """simple docstring""" __magic_name__ : Optional[int] = len(_A ) __magic_name__ : Tuple = int(math.floor(math.sqrt(_A ) ) ) __magic_name__ : Optional[int] = 0 w...
324
0
'''simple docstring''' 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 __snake_case ( unitt...
398
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( ...
398
1
"""simple docstring""" from collections.abc import Callable def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): __lowercase : float = a __lowercase : float = b if function(__UpperCamelCase ) == 0: ...
76
'''simple docstring''' def lowercase__ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase )-> Tuple: if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__UpperCamelCase , n - 1 , __UpperCamelCas...
301
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( ...
386
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> float: '''simple docstring''' if days_between_payments <= 0: raise ValueError("days_between_payments must be > 0" ) if daily...
386
1
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig 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_back...
532
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict SCREAMING_SNAKE_CASE_ : Optional[Any] = namedtuple( '''_TestCommandArgs'''...
375
0
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging UpperCamelCase = logging.get_logger(__name__) def _a ( lowerCamelCase__=None , lowerCamelCase__=None ) -> int:...
710
import warnings from .generation import TFGenerationMixin class lowerCamelCase__ ( UpperCAmelCase ): # warning at import time warnings.warn( 'Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ' 'be removed in T...
144
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging a_ ...
25
def A_ ( _UpperCAmelCase ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise TypeError("only integers accepted as input" ) else: SCREAMING_SNAKE_CASE_: List[Any] = str(abs(_UpperCAmelCase ) ) ...
671
0
from ..utils import DummyObject, requires_backends class lowercase__ (metaclass=lowercase__ ): """simple docstring""" __UpperCamelCase : Union[str, Any] = ["""transformers""", """torch""", """note_seq"""] def __init__( self : List[str] , *__a ...
715
import colorsys from PIL import Image # type: ignore def _lowercase ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_): """simple docstring""" snake_case__ : List[Any] = x snake_case__ : int = y for step in range(Uppe...
127
0
'''simple docstring''' from __future__ import annotations from collections import deque class _lowerCamelCase : '''simple docstring''' def __init__( self : Tuple , _A : list[str] ) -> Optional[Any]: __magic_name__ : list[dict] = [] self.adlist.append(...
561
'''simple docstring''' import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCamelCase ( lowerCAmelCase : int ...
561
1
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __a = argparse.ArgumentParser() parser.add_argument("--dump_path", default=...
310
"""simple docstring""" import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def A_ ( _lowercase, _lowercase, _lowercase, _lowercase ): '''simple docstring''' snake_case_ :Any = s.rsplit(_lowercase, ...
310
1