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
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _snake_case ( UpperCAmelCase_ ): def lowercase__ ( self): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2...
12
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def UpperCamelCase ( ) -> List[Any]: '''simple docstring''' raise RuntimeError("""CUDA out of ...
12
1
import copy import importlib.metadata import json import os from dataclasses import dataclass from typing import Any, Dict, Union from packaging import version from ..utils import is_torch_available, logging if is_torch_available(): import torch _lowerCamelCase : Tuple = logg...
702
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) _lowerCamelCase : ...
647
0
def _lowerCAmelCase ( A__ ): 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][cell_n] += grid[0][cell_n - 1] lowercase__ = grid[0] for ...
622
def _lowerCAmelCase ( A__ = 600_851_475_143 ): try: lowercase__ = int(A__ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater than or equa...
622
1
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`''')
452
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipel...
452
1
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCAmelCase = HfApi() _lowerCAmelCase = {} # fmt: off _lowerCAmelCase = torch.tensor([ -0.75_15, -1.68_83, 0.24_20, 0.03_00, 0.63_47, 1.34_33, -1.17_43, -3.74_67, 1....
137
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ......
137
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,...
704
"""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/lice...
327
0
def UpperCAmelCase__ ( __magic_name__ : int , __magic_name__ : int ): '''simple docstring''' while b: lowerCAmelCase , lowerCAmelCase : Tuple = b, a % b return a def UpperCAmelCase__ ( __magic_name__ : int , __magic_name__ ...
348
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
348
1
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate dep...
710
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch SCREAMING_SNAKE_CASE__ : List[Any] = """sshlei...
629
0
from numpy import exp, pi, sqrt def A__ ( SCREAMING_SNAKE_CASE_ : Any , SCREAMING_SNAKE_CASE_ : float = 0.0 , SCREAMING_SNAKE_CASE_ : float = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2...
32
"""simple docstring""" import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, W...
391
0
def _a ( UpperCamelCase_ : int ) -> int: """simple docstring""" if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(UpperCamelCase_ , UpperCamelCase_ ): raise TypeError("Input value must be a 'int' ...
115
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = logging.get_logger(__name__) a_ = {'''v...
115
1
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): UpperCamelCase : Optional[Any] = JukeboxTokenizer UpperCamelCase : int = {...
110
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoForme...
110
1
"""simple docstring""" from __future__ import annotations class UpperCamelCase__ : """simple docstring""" def __init__( self : Tuple , SCREAMING_SNAKE_CASE_ : str ): lowerCAmelCase_ : int = TypeErro...
720
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_fu...
317
0
import warnings from ..trainer import Trainer from ..utils import logging __a :Union[str, Any] = logging.get_logger(__name__) class _a ( snake_case_ ): """simple docstring""" def __init__( self : int , UpperCAmelCase : Optional[Any]...
86
class _a : """simple docstring""" def __init__( self : Union[str, Any] , UpperCAmelCase : int , UpperCAmelCase : Any , UpperCAmelCase : Dict ): A_ = None A_ = None A_ ...
86
1
"""simple docstring""" import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_comm...
708
"""simple docstring""" import functools def UpperCamelCase_ ( lowerCamelCase : str , lowerCamelCase : str ) -> int: """simple docstring""" __magic_name__ : List[str] = len(lowerCamelCase ) __magic_name__ : Dict = ...
147
0
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ) -> int: monkeypatch.setattr("""datasets.utils.deprecation_utils._emitted_deprecation_warnings""" ,set() ) @pytest.fixture def ...
17
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : List[Any] = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_...
139
0
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): snake_case_ : int = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: true\nsubsections:\n ...
166
import os import pytest from transformers.dynamic_module_utils import get_imports snake_case_ : Optional[int] = '\nimport os\n' snake_case_ : str = '\ndef foo():\n import os\n return False\n' snake_case_ : List[str] = '\ndef foo():\n def bar...
166
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__UpperCAmelCase ) class A ( __UpperCAmelCase ): lowerCamelCase : st...
325
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { "configuration_layoutlmv3": [ "LAYOUTLMV3_PRETRAI...
325
1
'''simple docstring''' def A (__lowerCamelCase :str = 1000 ): _lowerCAmelCase = 3 _lowerCAmelCase = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a +...
716
'''simple docstring''' from __future__ import annotations def A (__lowerCamelCase :list[int] ): if len(__lowerCamelCase ) == 0: return array _lowerCAmelCase , _lowerCAmelCase = min(__lowerCamelCase ), max(__lowerCamelCase ) # Compute the variables _lowerCAm...
162
0
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a_ = False class UpperCAmelC...
76
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ...
46
0
"""simple docstring""" from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class __magic_name__ : def __init__( self : Tuple , snake_case__ : Collection[float] | None = None ): '''simpl...
717
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, ...
475
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { 'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'], } try: if not is_torch...
523
'''simple docstring''' # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to...
523
1
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
366
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( _lowerCamelCase: Dict , _lowerCamelCase: str , _lowerCamelCase: Dict ) -> ...
366
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: List[str] ): SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = sum(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = [[False for x in range(s + 1 )] for y in range(n + 1 )] for...
6
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _UpperCAmelCase : List[str] = logging.get_logger(__name__) def UpperCAmelCase__ ( lowerCamelCase=None, lowerCamelCase=None ...
453
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = False ): if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check last digit return False if n > 3317044064679887385961981 and not allow_probable: raise Val...
453
1
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float , ): _UpperCAmelCase : Tuple = [redshift, radia...
506
"""simple docstring""" import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql i...
506
1
'''simple docstring''' from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require...
47
'''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 # ...
47
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class lowercase__ ( _UpperCAmelCase ): A__ : Union[List[P...
472
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def _lowercase ( UpperCamelCase_ ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE__ = [ 'encoder.version', 'decoder.version', ...
472
1
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestM...
350
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : Any = { 'configuration_electra': ['ELEC...
350
1
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowercase ( SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : ...
477
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCRE...
465
0
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import Tokeniz...
283
"""simple docstring""" from __future__ import annotations SCREAMING_SNAKE_CASE = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __lowerCAmelCase( __UpperCAmelCase ,__UpperCAmelCase ,__UpperCAmelCase ,__UpperCAmelCase ,__UpperCAmelCas...
283
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Any class lowerCamelCase : def __init__( self : Optional[Any] , __UpperCAmelCase : Any ) -> List[str]: SCREAMING_SNAKE_CASE...
196
"""simple docstring""" import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils...
196
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_tor...
706
'''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, convert_to_rgb, get_resize_output_image_size, normalize, rescale,...
233
0
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch...
33
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoF...
163
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, ...
709
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMSchedule...
372
0
from sklearn.metrics import mean_squared_error import datasets A__ : Tuple = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Prettenho...
233
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowercase ( __UpperCamelCase ): def __init__( self , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__=None , SC...
233
1
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ :List[Any] = logg...
250
from __future__ import annotations a_ :str = 8.988e9 # units = N * m^s * C^-2 def a ( A__ , A__ , A__ , A__ ) -> dict[str, float]: '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] = abs(chargea * chargea ) ...
250
1
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = 'T5Config' class _a ( UpperCamelCase__ ): _l...
43
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 rep...
43
1
def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' if number > 0: raise ValueError("input must be a negative integer" ) _UpperCamelCase = len(bin(a__ )[3:] ) _UpperCamelCase = bin(abs(a__ ) - (1 << binary_number_length) )[3:] _UpperCamelCase ...
82
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCAmelCase ( unittest.TestCase ): '''sim...
82
1
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu lowerCamelCase ...
667
'''simple docstring''' import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) fr...
667
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase :List[Any] = logging.get_logger(__name__) __lowercase :List[str] = { """google/pix2struct-textcaps-base""": ( """https://huggingface...
720
from __future__ import annotations from fractions import Fraction def UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : int ): '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num ...
26
0
'''simple docstring''' import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __lowerCAmelCase =HUGGINGFACE_HUB_CACHE __lowerCAmelCase ="config.json" __lowerCAmelCase ="diffusion_pytorch_model.bin" __lowerCAmelCase ="diffusion_flax_model.msgpack" __lowerCAmelCase ...
697
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase =logging.get_logger(__name__) __lowerCAmelCase ={ "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json...
697
1
'''simple docstring''' import numpy as np import qiskit def snake_case_ (UpperCamelCase : int = 8 , UpperCamelCase : int | None = None ): '''simple docstring''' _a = np.random.default_rng(seed=UpperCamelCase ) # Roughly 25% of the...
377
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) _snake_case : List[Any] = {'configuration_beit': ['BEIT_PRETRAINED_CON...
377
1
from functools import lru_cache def UpperCAmelCase__ (UpperCamelCase_ ): """simple docstring""" snake_case = 2 snake_case = set() while i * i <= n: if n % i: i += 1 else: n ...
550
class A__ : """simple docstring""" def __init__( self , __snake_case ): snake_case = n snake_case = [None] * self.n snake_case = 0 # index of the first element snake_case ...
550
1
def lowerCamelCase_ ( _lowercase , _lowercase ) -> str: __A : List[str] = "" for i in table: res += inp[i - 1] return res def lowerCamelCase_ ( _lowercase ) -> Union[str, Any]: return data[1:] + data[0] def ...
709
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common impor...
387
0
'''simple docstring''' def __UpperCamelCase ( lowercase__ : Tuple ): '''simple docstring''' __lowercase =len(lowercase__ ) __lowercase =sum(lowercase__ ) __lowercase =[[False for x in range(s + 1 )] for y in range(n + 1 )] for i in ...
119
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available...
119
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) class _UpperCAmelCase ( __snake_case ): '''simple docstring''' def __in...
229
"""simple docstring""" def lowercase ( _snake_case : Union[str, Any] ) ->Optional[int]: """simple docstring""" if not head: return True # split the list to two parts __snake_case , __snake_case : str = head.next, head while fast and fast.next: __snake_case : Lis...
229
1
"""simple docstring""" from math import sqrt def a ( __UpperCAmelCase : int ) -> bool: assert isinstance(__UpperCAmelCase , __UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" __magic_name__...
96
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def a ( __UpperCAmelCase : str ) -> Optional[int]: def decorator(__UpperCAmelCase : List[str] ): __magic_name__: Union[str, Any] = ...
96
1
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSchedule...
711
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_ ( lowerCamelCase : int ) -> bool: """simple docstring""" __magic_name__ : int = int(number**0.5 ) ret...
147
0
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.""" )
166
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokenizati...
298
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ = { """configuration_mobilebert""": [ """MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mo...
704
from __future__ import annotations import time a__ = list[tuple[int, int]] a__ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], ...
99
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertMo...
59
from __future__ import annotations from math import pi def lowerCAmelCase_ ( __a , __a , __a ) -> dict[str, float]: """simple docstring""" if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError("One and only one argument must be...
59
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, ...
375
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> str: """simple docstring""" ...
375
1
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from d...
7
import csv import tweepy # Twitter API credentials lowerCAmelCase__ = '' lowerCAmelCase__ = '' lowerCAmelCase__ = '' lowerCAmelCase__ = '' def __lowercase ( _UpperCAmelCase ) -> None: '''simple docstring''' __lowercase = tweepy.OAuthHandler(_U...
321
0
"""simple docstring""" from __future__ import annotations lowerCAmelCase_ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '...
494
"""simple docstring""" import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def __lowerCamelCase ( SCREAMING_SNAKE_CASE ) -> str: """simple docstring""" _UpperCAmelCase = [ ...
494
1
'''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=_a ) class a__( _a ): a_ : Optional[int] = field(default='''audio-classi...
538
__snake_case = { '''a''': '''AAAAA''', '''b''': '''AAAAB''', '''c''': '''AAABA''', '''d''': '''AAABB''', '''e''': '''AABAA''', '''f''': '''AABAB''', '''g''': '''AABBA''', '''h''': '''AABBB''', '''i''': '''ABAAA''', '''j''': '''BBBAA''', '''k''':...
1
0
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class __magic_name__ ( snake_case__ ): UpperCAmelCase =(...
702
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class __magic_name__ ( lowerCAmelCase ): UpperCAmelCase ="EncodecFeatureExtractor" UpperCAmelCase =("T5Tokeniz...
331
0
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _...
57
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import...
628
0
def __UpperCAmelCase ( snake_case_ : Dict = 1_0_0 ): '''simple docstring''' UpperCAmelCase: Any = set() UpperCAmelCase: List[str] = 0 UpperCAmelCase: Union[str, Any] = n + 1 # maximum limit for a in range(2 , __UpperCamelCase ): for b...
713
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCAmelCase ( snake_case_ : int = 3 ): '''simple docstring''' if isinstance(snake_case_ , snake_case_ ): rai...
166
0
import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import req...
105
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCamelCase_ ( __UpperCamelCase = "" ): A_ = url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250''' A_ = BeautifulSoup(requests.get(__UpperCamelCase ).text ...
141
0
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase , __lowerCAmelCase ): snake_case__ , snake_case__ = set(__lowerCAmelCase ), [start] while stack: snake_case__ = stack.pop() explored.add(__lowerCAmelCase ...
530
import os import re import shutil import sys import tempfile import unittest import black __magic_name__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_copies # noqa: E402 # This is the reference c...
530
1
'''simple docstring''' import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCas...
640
'''simple docstring''' from PIL import Image def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase ) -> Image: '''simple docstring''' def brightness(__UpperCAmelCase ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: ...
640
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Optional[Any] = logging.get_logger(__name__) A__ : Dict = { """Salesforce/blip-vqa-base""": """https://huggingface.c...
660
"""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 from ..auto import CONFIG_MAPPING A__ : Union[str, Any] = logging....
660
1
'''simple docstring''' from math import sqrt def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: A_ = 0 for i in range(1, int(sqrt(UpperCAmelCase__ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCAmelCase__ ): ...
288
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ...
288
1
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowerCAmelCase_ ( A__ ): '''simple docstring''' def A__ ( self , snake_case_ ) -> Optional[int]: ...
704
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowercase (_lowerCAmelCase ): __lowerCAmelCase = prime_factors(_lowerCAmelCase ) if is_square_free(_lowerCAmelCase ): return -1 if len(_lowerCAme...
573
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="""session""" ) def snake_case_ ( ): __lowercase : Opti...
149
from math import factorial def snake_case_ ( lowerCAmelCase_ : int = 100 ): return sum(map(lowerCAmelCase_ , str(factorial(lowerCAmelCase_ ) ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
149
1
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging __magic_name__ =logging.get_logger(__name__) def __UpperCamelCase ...
702
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _A ( unittest.TestCase ): ...
469
0
from __future__ import annotations SCREAMING_SNAKE_CASE_ = 'Muhammad Umer Farooq' SCREAMING_SNAKE_CASE_ = 'MIT' SCREAMING_SNAKE_CASE_ = '1.0.0' SCREAMING_SNAKE_CASE_ = 'Muhammad Umer Farooq' SCREAMING_SNAKE_CASE_ = 'contact@muhammadumerfarooq.me' SCREAMING_SNAKE...
300
"""simple docstring""" from __future__ import annotations import time A : List[str] = list[tuple[int, int]] A : Tuple = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, ...
516
0
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> int: '''simple docstring''' _lowerCamelCase : int = [] _lowerCamelCase : List[str] ...
709
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> list[str]: '''simple docstring''' if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_byte...
386
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transforme...
174
"""simple docstring""" def lowerCAmelCase_ ( snake_case_ : str , snake_case_ : str = " " ) ->list: lowerCamelCase__ : str =[] lowerCamelCase__ : int =0 for index, char in enumerate(snake_case_ ): if char == separator: ...
174
1
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 ): lowerCAmelCase_ = ['image_p...
721
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_t...
11
0
def _a ( UpperCamelCase_ : list[int] ) -> list[list[int]]: """simple docstring""" lowerCAmelCase__ = [] if len(UpperCamelCase_ ) == 1: return [nums.copy()] for _ in range(len(UpperCamelCase_ ) ): lowerCAmelCase__ = nums.po...
339
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization...
339
1
'''simple docstring''' from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCamelCase ( lowerCamelCase_ : int ): """simple docstring""" UpperCAmelCase_ : Optional[Any] = prime_factors(lowerCamelCase_ ...
389
'''simple docstring''' import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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 ImageProcessingSa...
389
1
"""simple docstring""" import argparse import os import re a_ : Optional[Any] = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ : Optional[Any] = re.compile...
594
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
594
1
import os import sys import unittest _snake_case : str = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_o...
715
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def _A...
214
0
from __future__ import annotations import math def __a ( A__ : int ): if num <= 0: SCREAMING_SNAKE_CASE = F"{num}: Invalid input, please enter a positive integer." raise ValueError(A__ ) SCREAMING_SNAKE_CASE = [True] * (num...
16
"""simple docstring""" import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, requ...
169
0
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): f...
70
import numpy as np _UpperCAmelCase = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ] ...
70
1
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModel...
28
'''simple docstring''' from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def lowercase__( ): """simple docstring""" SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : str = 9, 14 ...
28
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modelin...
128
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _SCREAMING_SNAKE_CASE : """simple docstring""" _a : int _a : Node | Non...
128
1
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard ...
362
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch _UpperCAmelCase : Dict = """sshleifer/bart-tiny-random"...
362
1
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): for i in range(len(__SCREAMING_SNAKE_CASE ) - 1 , 0 , -1 ): lowercase = False for j in range(__SCREAMING_SNAKE_CASE , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: lowercase ...
703
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): if "model" in orig_key: lowercase = orig_key.replace('model.' , '' ) if "norm1" in orig_key: lowercase = orig_key.repla...
565
0
'''simple docstring''' import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterabl...
427
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArgument...
563
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, D...
712
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot import Blende...
594
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar __lowercase : int = TypeVar("""T""") class lowerCAmelCase ( Generic[T] ): """simple docstring""" def __init__( self...
142
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __lowercase : int = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": oper...
142
1
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf, ...
264
def lowerCAmelCase_ ( lowercase: float ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(lowercase , lowercase ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def lowerCAmelCase_ ...
264
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_visio...
42
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = {"""vocab_file""": """vocab.txt"""} ...
147
0
from math import pi, sqrt def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> float: if num <= 0: raise ValueError("math domain error" ) if num > 171.5: raise OverflowError("math range error" ) elif num - int(SCREAMING_SNAKE_CASE_ ...
298
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import...
298
1
"""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_tensor if is_flax...
353
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation UpperCAme...
420
0
'''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...
703
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase = { '''configuration_vision_encoder_decoder''': ['''VisionEnc...
41
0
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenizer ...
548
from __future__ import annotations def A__ ( lowerCamelCase ) -> int: UpperCamelCase_: Optional[Any] = len(lowerCamelCase ) // 2 # choose the middle 3 elements UpperCamelCase_: Tuple = lst[m - 1 : m + 2] # if middle element is peak if three[...
548
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, ) __UpperCAmelCase = { """configuration_blenderbot_small""": [...
79
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __UpperCAmelCase = {"""UserAgent""": UserAgent().random} def __A ( lowerCamelCase_ ): """simple docstring""" SCREAMING_SNA...
79
1
'''simple docstring''' from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMSc...
390
'''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_channel_dim...
390
1
def __lowercase( UpperCAmelCase__ = 100 ): """simple docstring""" lowerCamelCase = set() lowerCamelCase = 0 lowerCamelCase = n + 1 # maximum limit for a in range(2 , __SCREAMING_SNAKE_CASE ): for b in range(2 , __SCREAMING_SNAKE_...
704
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, ...
484
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
605
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 ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices...
605
1
'''simple docstring''' import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowerCamelCase__( ctypes.Structure ): # _fields is a specific attr expected by ctypes UpperCamelCase : Dict ...
339
'''simple docstring''' from __future__ import annotations def lowercase__ ( __UpperCamelCase : list[float] ): '''simple docstring''' __lowercase = 0.00 __lowercase = 0 for resistor in resistors: if resistor <= 0: __lowercase ...
339
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Dict = logging.get_logger(__name__) _a : Union[str, Any] = { """google/vivit-b-16x2-kinetics400""": ( """https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json""" ...
145
_a : str = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _a : int = [{"""type""":...
145
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a : List[str] = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
200
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class _SCREAMING_SNAKE_CASE ( nn.Module ): """simple docstring""" ...
200
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization...
112
'''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...
44
0
from math import pi def snake_case_ ( __lowercase , __lowercase ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
641
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase__: '''simple docstring''' A_ : torch.Tensor # [batch_size x 3] A_ : torch.Tensor # [batch_size x 3] A_ : torch.Ten...
641
1
import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class lowerCAmelCase_ : """simple docstring""" def __init__( self :str , lowerCamelCase__ :Dict ): ...
45
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowerCamelCase = { "configuration_falcon": ["FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP", "FalconConfig"], } try: if not...
536
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets __lowerCamelCase = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For b...
536
1