code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def __magic_name__ ( A : str, A : int ): '''simple docstring''' a = [[] for _ in range(A )] a = key - 1 if key <= 0: raise ValueError("Height of grid can't be 0 or negative" ) if key == 1 or len(A ) <= key: return input_string for posi...
107
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class snake_case__ : """simple docstring""" SCREAMING_SNAKE_CASE_ : str ...
107
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=_SCREAMING_SNAKE_CASE ) class a ( _SCREAMING_SNAKE_CASE ): _lowerCAmelCase = field(default=...
358
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : List[str] = logging.get_logger(__name__) a_ : str = { "microsoft/git-base": "https://hug...
104
0
from __future__ import annotations def a_ ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : Optional[int] = None , SCREAMING_SNAKE_CASE__ : List[Any] = None ): '''simple docstring''' if start is None: _lowerCamelCase : ...
199
import unittest from transformers import LiltConfig, 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 ModelTesterMixin, ids_te...
343
0
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
354
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_...
258
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplingE...
43
'''simple docstring''' def __magic_name__( lowerCamelCase): __lowerCAmelCase = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowerCAmelCase = set() return any( node not in visited and depth_first_searc...
174
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/l...
369
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteSchedul...
324
0
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def lowerCamelCase_ ( _UpperCamelCase = "laptop" ) -> DataFrame: """simple docstring""" snake_case_ : Any = f'''https://www.amazon.in/laptop/s?k={produ...
279
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = {name: getattr(transformers, name + """Fast""") for n...
325
0
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device A__ : Optional[Any] ...
220
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, ...
220
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE :Union[str, Any] = { '''configuration_lxmert''': ['''LXMERT_PRETRAINED_CONFI...
159
"""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.ge...
113
0
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseConfig, B...
354
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, t...
141
0
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph class ...
9
"""simple docstring""" from typing import Any class lowerCamelCase : def __init__( self : Tuple , __UpperCAmelCase : Any ) -> Optional[Any]: SCREAMING_SNAKE_CASE__ = data SCREAMING_SNAKE_CASE__ = None def __repr__(...
165
0
"""simple docstring""" from math import sqrt def a__ ( SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' lowerCAmelCase : Dict = 0 for i in range(1 , int(sqrt(lowercase__ ) + 1 ) ): if n % i == 0 and i != sqrt(lowercase__ )...
363
"""simple docstring""" import baseaa def a__ ( SCREAMING_SNAKE_CASE : str ): '''simple docstring''' return baseaa.baaencode(string.encode("utf-8" ) ) def a__ ( SCREAMING_SNAKE_CASE : bytes ): '''simple docstring''' return baseaa.baadecode(SCREAMI...
133
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ...
75
import numpy as np from PIL import Image def _a ( lowerCamelCase: np.ndarray , lowerCamelCase: int , lowerCamelCase: int ) -> np.ndarray: '''simple docstring''' __A = np.array(lowerCamelCase ) if arr.shape[0] != a...
117
0
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _snake_case(...
282
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_...
282
1
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) UpperCAmelCase_ : List[Any] = logging.getLogger(__name__) if __name__ ==...
38
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record UpperCAmelCase_ : int = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems}, author={Wa...
38
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def A__ ( lowerCamelCase ) -> Optional[Any]: monkeypatch.setattr("""datasets.utils.deprecation_utils._emitted_deprecation_warnings""" , set() ) @pytest.fixture def A__ ( lower...
370
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Optional[int] = logging.get_logger(__name__) lowerCamelCase_ : Dict = { """studio-ousia/luke-base""": """https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json""", """studio-o...
223
0
from ...processing_utils import ProcessorMixin class lowercase ( lowercase_ ): __SCREAMING_SNAKE_CASE : int = '''WhisperFeatureExtractor''' __SCREAMING_SNAKE_CASE : Any = '''WhisperTokenizer''' def __init__( self , snake_case , snake_c...
285
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 flax.jax_utils import replicate ...
285
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __A ={ "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torc...
362
'''simple docstring''' import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __A ='\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification},\...
283
0
def a__ ( A_, A_, A_ ): '''simple docstring''' def update_area_of_max_square(A_, A_ ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 __magic_name__ = update_area_of_max_square(A_, col + 1 ) __magic...
88
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): lowercase__ : Optional[int] = 1 for i in range(1 , num + 1 ): fact *= i return fact def __UpperCamelCase ( UpperCAmelCase ): lowercase__ : Optional[Any] = 0 while number > 0: lowercase_...
198
0
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def SCREAMING_SNAKE_CASE ( ...
368
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> list[int]: a = 2 a = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(__UpperCamelCase) if n...
180
0
'''simple docstring''' import numpy as np from transformers import Pipeline def __snake_case ( UpperCAmelCase_ : Dict ): lowerCamelCase_ = np.max(UpperCAmelCase_ , axis=-1 , keepdims=UpperCAmelCase_ ) lowerCamelCase_ = np.exp(outputs - maxes ) ...
55
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, Be...
241
0
"""simple docstring""" from numpy import exp, pi, sqrt def lowerCAmelCase__ ( _UpperCamelCase : str , _UpperCamelCase : float = 0.0 , _UpperCamelCase : float = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2...
149
"""simple docstring""" import os def lowerCAmelCase__ ( _UpperCamelCase : str = "matrix.txt" ) -> int: """simple docstring""" with open(os.path.join(os.path.dirname(_UpperCamelCase ) , _UpperCamelCase ) ) as in_file: snake_ca...
149
1
"""simple docstring""" import numpy as np def a_ ( lowerCamelCase , lowerCamelCase , lowerCamelCase = 1e-1_2 , lowerCamelCase = 1_0_0 , ): assert np.shape(lowerCamelCase )[0] == np.shape(lowerCamelCase )[1] # Ensure proper dimensionality. assert np.sha...
98
"""simple docstring""" def a_ ( lowerCamelCase ): return str(lowerCamelCase ) == str(lowerCamelCase )[::-1] def a_ ( lowerCamelCase ): return int(lowerCamelCase ) + int(str(lowerCamelCase )[::-1] ) def a_ ( lowerCamelCase = 1...
98
1
'''simple docstring''' from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( B...
240
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCAmelCase :Union[str, Any] = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], ...
240
1
from math import log from scipy.constants import Boltzmann, physical_constants lowercase : Dict = 3_0_0 # TEMPERATURE (unit = K) def A_ ( A__ , A__ , A__ , ) -> float: if donor_conc <= 0: raise ValueError('Donor concentration should be positive'...
99
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : List[Any] = logging.get_logger(__name__) lowercase__ : str = {} class SCREAMING_SNAKE_CASE (a__ ): lowerCAmelCase =...
190
0
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArgume...
357
'''simple docstring''' import math def a_ ( lowerCamelCase : int ): lowerCAmelCase = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowerCamelCase ) def a_ ( lowerCamelCase : float = 1 ...
55
0
def a_ ( __lowercase : int = 1_000_000 ) -> int: _snake_case = set(range(3 , __lowercase , 2 ) ) primes.add(2 ) for p in range(3 , __lowercase , 2 ): if p not in primes: continue primes.difference_update(set(range(p * p , ...
282
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class S...
282
1
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class UpperCamelCase_ : _A : Dict = None _A : Optional[int] = False _A : Union[str, Any] = False _A : str = Fa...
366
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = (...
248
0
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def __lowerCamelCase ( _lowercase , _lowercase , _lowercase = 1 / sqrt(2 ) ) -> IIRFilter: UpperCAmelCase : Optional[int] = tau * frequency / samplerat...
265
def A_ ( _lowerCAmelCase ) -> str: UpperCamelCase : List[Any] = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def A_ ( _lowerCAmelCase ) -> dict[str, str]: UpperCamelCase : Optional[An...
52
0
'''simple docstring''' import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCal...
299
'''simple docstring''' import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers....
299
1
"""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...
292
"""simple docstring""" import inspect import unittest from transformers import ViTMSNConfig 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 Co...
292
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_confi...
359
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class snake_case_( a__ ): __UpperCamelCase = (DDPMScheduler,) def lowerCamelCase__ ( self : List[Any] , **UpperCamelCase_ :...
314
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, get...
244
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''', '''uclanlp/visualbert-vqa-pre'''...
244
1
'''simple docstring''' 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 lowercase_ (unittest.TestCase ): """simple docstring"...
369
'''simple docstring''' from math import sqrt def _A ( A__ ): """simple docstring""" assert isinstance(A__ , A__ ) and ( number >= 0 ), "'number' must been an int and positive" __lowercase = True # 0 and 1 are none primes. if number <= 1: __lowercase ...
52
0
'''simple docstring''' import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import ...
272
import sys from collections import defaultdict class __UpperCamelCase : """simple docstring""" def __init__( self : Union[str, Any] ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[int] = [] def UpperCAmelCas...
303
0
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import Atten...
360
import argparse import os 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_task_guides.py lowerCAmelCase__ : Optional[Any] ='src/transformers' lowerCAmelC...
162
0
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() __a :Optional[Any] = loggin...
312
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer __a :List[str] = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} _...
312
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer lowercase_ = logging.get_logger(__name__) lowercase_ = {...
354
def _snake_case( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : list[list[int]] ) -> int: '''simple docstring''' def update_area_of_max_square(SCREAMING_SNAKE_CASE__ : int ...
282
0
'''simple docstring''' from manim import * class SCREAMING_SNAKE_CASE( A__ ): """simple docstring""" def A ( self : Union[str, Any] ) -> List[str]: UpperCAmelCase : Optional[Any] = Rectangle(height=0.5 , widt...
23
'''simple docstring''' import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_...
23
1
"""simple docstring""" 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 __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __Upp...
309
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Dict = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctc...
309
1
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...image_...
240
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class A_ (a_ ): UpperCAmelCase__ = 42 UpperCAmelCase_...
273
0
from __future__ import annotations def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): SCREAMING_SNAKE_CASE_ , SCREAMING...
257
from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=__SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCAmelCase_ =["transformers", "torch", "note_seq"] def __init__( self , *_A , **_A ) ...
257
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging loggi...
231
from pathlib import Path import fire def lowerCamelCase__ ( __lowerCAmelCase : str , __lowerCAmelCase : str , __lowerCAmelCase : int ): """simple docstring""" lowerCAmelCase_ = Path(__lowerCAmelCase ) lowerCAmelCase_ = Path(__lowerCAmelCase ) ...
231
1
'''simple docstring''' from __future__ import annotations def a ( __a , __a = None , __a = None , __a = False , ) -> tuple[int, float, str]: '''simple docstring''' UpperCamelCase__ :Optional[Any] = cipher_alphabet or [chr(__a ) for i in range(97 ...
360
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when sw...
219
0
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ....
44
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 __SCREAMING_SNAKE_CASE ( snake_case_ , snake_case_ ): '''sim...
133
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : str = logging.get_logger(__name__) _UpperCAmelCase : Optional[int] = { "caidas/swin2sr-classicalsr-x2-64": ( "https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/m...
110
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowercase ( _SCREAMING_SNAKE_CASE , unittest.TestCase ): __lowercase : Any = CTRLTokenizer...
110
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ...
29
import logging from transformers import PretrainedConfig a__ = logging.getLogger(__name__) a__ = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', } class UpperCAmelCase_ ( __...
235
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version snake_case_ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk import word_tokenize s...
238
from __future__ import annotations snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'MIT' snake_case_ = '1.0.0' snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'contact@muhammadumerfarooq.me' snake_case_ = ...
238
1
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig 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_co...
126
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase_ ( snake_case_ : Dict , snake_case_ : str , snake_case_ : str ,...
126
1
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> Any: __lowerCamelCase : int = [0] * len(lowerCamelCase__ ) __lowerCamelCase : Any = [] __lowerCamelCase : Optional[int] = [] __lowerCamelCase : Dict = 0 for values in graph.values(): for i in...
113
# 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 ...
113
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.de...
157
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_to...
148
0
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=a_ ): """simple docstring""" lowercase__ = ["sentencepiece"] def __init__( self : Dict ,*lowercase_ : Tuple ,**lowercase_ : Dict ): requ...
351
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def __SCREAMING_SNAKE_CASE ( A_ , A_ , A_ ): if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if resistance == 0: return {"r...
74
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @requir...
11
'''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 ( OPENA...
198
0
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __lowerCamelCase ( __UpperCamelCase ) -> List[Any]: """simple docstring""" lowerCAmelCase_ : Tuple = os.pa...
161
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForCo...
161
1
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 __A = { # 1536-bit 5: { "prime": int( "FFFFFFFFFFFFFFFFC9...
10
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokenize...
102
0
'''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 # #...
17
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'huggingface/time-series-transformer-tourism-monthly': ( 'https://huggingface.co/huggingface...
17
1
'''simple docstring''' def a ( lowerCamelCase__ ): '''simple docstring''' return str(lowerCamelCase__ ) == str(lowerCamelCase__ )[::-1] def a ( lowerCamelCase__ ): '''simple docstring''' return int(lowerCamelCase__ ) + int(str(lowerCamelCase__ )[::-1] ) def...
206
'''simple docstring''' import re def a ( lowerCamelCase__ ): '''simple docstring''' return [char.split() for char in re.split(r"""[^ a-z A-Z 0-9 \s]""" , str_ )] def a ( lowerCamelCase__ ): '''simple docstring''' A_ : Optional[int] = split_input(str_...
206
1
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _a ( unittest.TestCase ): """simple docstring""" def __A ( self : str ): debug_launcher(tes...
329
from math import isqrt, loga def __snake_case ( __UpperCamelCase : int ): """simple docstring""" A_ = [True] * max_number for i in range(2 ,isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 ,...
329
1
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_t...
106
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , low...
171
0
def lowerCAmelCase_ ( snake_case_ ): _A : Optional[Any] = int(SCREAMING_SNAKE_CASE__ ) if n_element < 1: _A : Optional[int] = ValueError("""a should be a positive number""" ) raise my_error _A : Optional[Any] = [1] ...
367
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _snake_case = "https://www.indeed.co.in/jobs?q=mobile+app+development&l=" def lowerCAmelCase_ ( snake_case_ = "mumbai" ): _A : Optional[Any] = ...
343
0
"""simple docstring""" import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( """The `image_to_image.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionImg2ImgPipeline` instead.""" )
224
"""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, ) lowercase__ : ...
224
1
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def __magic_name__ ( A , A , A , A , ) -> list[float]: snake_case , snake_case = coefficient_matrix.shape snake_case , snake_case ...
358
'''simple docstring''' import pytest lowerCAmelCase_ = "__dummy_dataset1__" lowerCAmelCase_ = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", ...
332
0
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, T...
110
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: lowercase__ = _modexpt(SCREAMING_SNAKE_CASE , exponent // 2 , SCREAMI...
110
1
'''simple docstring''' 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.te...
361
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification ...
187
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][...
37
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase = { """configuration_roberta""": ["""ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP""", "...
186
0
'''simple docstring''' import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup __lowercase : str = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36' ' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 E...
294
'''simple docstring''' from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('To use the rich extension, install rich with `pip install rich`')
294
1
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( ...
113
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is...
113
1
import math import random def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ = False ): """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value _SCREAMING_SNAKE_CASE : Li...
213
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipel...
213
1
def UpperCAmelCase_ ( __snake_case , __snake_case ) -> int: """simple docstring""" return x if y == 0 else greatest_common_divisor(__a , x % y ) def UpperCAmelCase_ ( __snake_case , __snake_case ) -> int: """simple d...
5
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A : Union[str, Any] = logging.get_logger(__name__) A : int = { '''xlm-roberta-base''': '''...
274
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 _UpperCamelCase : List[str] = logging.get...
186
"""simple docstring""" def snake_case (A_ :int ): '''simple docstring''' if isinstance(A_ , A_ ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(A_ , A_ ): raise TypeError('\'str\' object cannot be interpreted...
186
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/mai...
173
"""simple docstring""" from ..utils import DummyObject, requires_backends class a ( metaclass=UpperCAmelCase__ ): UpperCamelCase : Optional[int] = ['torch', 'torchsde'] def __init__( self : Union[str, Any] , *lowerCAmelCase : Any , **lowerCAme...
173
1
from ...processing_utils import ProcessorMixin class a (_lowerCAmelCase ): """simple docstring""" __UpperCAmelCase : Any = ["image_processor", "feature_extractor"] __UpperCAmelCase : Optional[int] = "TvltImageProcessor" __UpperCAmelCase : ...
134
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): if index == r: for j in range(__lowerCamelCase ): print(data[j] , ...
134
1
"""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 # ...
17
"""simple docstring""" from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
17
1
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : Optional[int] = word.split() def justify(SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : int ...
357
"""simple docstring""" from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''huggingface/autoformer-tourism-monthly''': '''https://huggingface....
133
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", } class a_ ...
58
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowercase : Any = (7_2_0, 1_2_8_0) # Height, Width _lowercase : List[Any] = (0.4, 0.6) # if height or width ...
93
0
from manim import * class SCREAMING_SNAKE_CASE__ ( lowercase__ ): def SCREAMING_SNAKE_CASE ( self : Optional[int] ) -> Optional[Any]: a_ : Tuple = Rectangle(height=0.5 , width=0.5 ) a_ : Dict = Rectangle(height=0.46 ...
362
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : Dict = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependenc...
120
0
"""simple docstring""" def __a ( __lowerCamelCase, __lowerCamelCase ): while b: UpperCAmelCase_ , UpperCAmelCase_ : Dict = b, a % b return a def __a ( __lowerCamelCase, __lowerCamelCase ): return a if b == 0 else euclidean_gcd_recursive(__lowerCamelCas...
61
from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { """microsoft/trocr-base-handwritten""": ( """https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.js...
343
0
__UpperCamelCase : str = tuple[float, float, float] __UpperCamelCase : Union[str, Any] = tuple[float, float, float] def __A ( __lowerCamelCase , __lowerCamelCase ) -> Vectorad: a = end_pointa[0] - end_pointa[0] a = end_pointa[1] ...
347
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __UpperCamelCase : Union[str, Any] = (720, 1_280) # Height, Width __UpperCamelCase : Any = (0.4, 0.6) # if height or width lower than this scale, drop it. __Upp...
347
1
"""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 = logging.get_logger(__name__) _A ...
242
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _A = logging.get_logger(__name__) class _lowerCamelCase : def __init__( sel...
242
1
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as comput...
355
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''google...
42
0
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, tor...
332
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _A ( ): """simple docstring""" with offline(OfflineSimulationMode.CONNECT...
104
0
from __future__ import annotations from typing import Any class __lowerCAmelCase : def __init__(self , __magic_name__ , __magic_name__ , __magic_name__ = 0 ) -> None: '''simple docstring''' snake_case_ , snake_case_ : Tuple ...
279
import random from .binary_exp_mod import bin_exp_mod def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase=1_000 ) -> str: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd snake_case_ ...
279
1
'''simple docstring''' from math import isclose, sqrt def SCREAMING_SNAKE_CASE__ ( __A , __A , __A ) -> tuple[float, float, float]: _snake_case = point_y / 4 / point_x _snake_case = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) _snake_case ...
42
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller __lowerCamelCase : List[str] = 3 def SCREAMING_SNAKE_CASE ( snake_case_ : int ): print("Generating primitive root of p" ) while True: snake_case__ ...
286
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 SCREAMING_SNAKE_CASE__ ( UpperCa...
286
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_torc...
282
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class S...
282
1
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": _snake_case : Optional[Any] = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, required...
359
from functools import lru_cache @lru_cache def a_ ( lowerCAmelCase_ : int ): if num < 0: raise ValueError('Number should not be negative.' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.testmod()
207
0
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tenso...
165
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnP...
261
0
"""simple docstring""" import os import pytest from transformers.dynamic_module_utils import get_imports _lowercase : int = '\nimport os\n' _lowercase : int = '\ndef foo():\n import os\n return False\n' _lowercase : str = '\ndef foo():\n def bar():...
86
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_av...
86
1
from math import ceil, sqrt def UpperCAmelCase ( a_ = 1_0_0_0_0_0_0 ) -> int: """simple docstring""" __A = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __A = max(ceil(sqrt(outer_width**2 - limit ) ) ...
15
'''simple docstring''' 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 .toke...
134
0
import argparse import json from tqdm import tqdm def _a ( ) -> Optional[int]: a = argparse.ArgumentParser() # Required parameters parser.add_argument( '''--src_path''' , type=a , default='''biencoder-nq-dev.json''' , help='''Path to raw DPR tra...
371
import math def _a ( a :int = 100 ) -> int: a = sum(i * i for i in range(1 , n + 1 ) ) a = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squares if __name__ == "__main__": print(f...
26
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCamelCase ( metaclass=lowerCAmelCase__ ): SCREAMING_SNAKE_CASE_ = ["speech"] def __init__( self, *lowerCAmelCase__, **lowerCAmelCase__) -> List[Any]: require...
69
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCamelCase ( lowerCAmelCase__ ): ...
69
1
"""simple docstring""" import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProces...
154
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class UpperCamelCase__( __A ...
154
1
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax if is_torch...
107
from __future__ import annotations class _a : def __init__( self: Union[str, Any] , UpperCamelCase_: str , UpperCamelCase_: str ) -> List[Any]: """simple docstring""" lowercase__ , lowercase__ =...
110
0
'''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_backbone_...
354
'''simple docstring''' def __lowerCamelCase ( A__ ) -> Union[str, Any]: """simple docstring""" UpperCamelCase = [0] * len(A__ ) UpperCamelCase = [] UpperCamelCase = [] UpperCamelCase = 0 for values in graph.value...
249
0
"""simple docstring""" __SCREAMING_SNAKE_CASE : List[Any] = tuple[float, float, float] __SCREAMING_SNAKE_CASE : Optional[int] = tuple[float, float, float] def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Vectorad: snake_case_ = end_point...
347
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.uti...
347
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer/resolve/main/config.json''', } class snake_case__(__a ): ...
369
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
121
0
'''simple docstring''' def a_ ( lowerCamelCase : int ): lowerCAmelCase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
4
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
from __future__ import annotations from typing import Any class lowerCamelCase ( A_ ): pass class lowerCamelCase : def __init__(self : Tuple , _A : Any ) -> None: snake_case = data snake_case...
137
import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "nvidia/segformer-b0-fine...
137
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decision-transformer-gym-hopp...
0
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowerCAmelCase_ = { '''linear''': PIL.Image.Resampling.BILINEAR, '''bilinear''': PIL.Image.Resampling.BILINEAR, ...
279
0
"""simple docstring""" import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ): """simple docstring""" _UpperC...
354
"""simple docstring""" def __UpperCAmelCase ( lowercase ): """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
30
0