code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class __SCREAMING_SNAKE_CASE (unitte...
692
"""simple docstring""" import math def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): return math.pow(SCREAMING_SNAKE_CASE , 2 ) - a def UpperCamelCase (SCREAMING_SNAKE_CASE ): return 2 * x def UpperCamelC...
102
0
def A ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ) -> List[str]: '''simple docstring''' if index == r: for j in range(__UpperCAmelCase ): ...
561
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase_ = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.model"...
561
1
def a__ ( A_ ): '''simple docstring''' if not isinstance(A_, A_ ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" ) return sum( divisor for divisor in range(1, input_num // 2 + 1 ) ...
529
import argparse import collections import os import re 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_table.py __lowerCAmelCase : Dict = 'src/transformer...
529
1
'''simple docstring''' import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": __lowerCamelCase : Optional[int] = "%20".join(argv[1:]) if len(argv) > 1 else quote...
459
'''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 UpperCAmelCase : UpperCAmelCase : int UpperCAmelCase : Node | None = None UpperCAmelCase...
459
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _UpperCamelCase = { 'configuration_la...
459
'''simple docstring''' import argparse from collections import defaultdict import yaml _UpperCamelCase = 'docs/source/en/_toctree.yml' def a_ ( _lowerCAmelCase ) -> Any: __lowerCamelCase : Optional[int] = defaultdict(_lowerCAmelCase ) __lowerCam...
459
1
'''simple docstring''' def UpperCAmelCase_ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ ): '''simple docstring''' if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vertex is not alrea...
41
'''simple docstring''' from __future__ import annotations def UpperCAmelCase_ ( lowercase__ ): '''simple docstring''' a_ =str(lowercase__ ) return len(lowercase__ ) == 9 and set(lowercase__ ) == set("123456789" )...
41
1
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def _UpperCamelCase ( lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : Tuple = F'''{sampling_rate}''' __SCREAMING_SNAKE_CASE : str = '''1'''...
696
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase : List[Any] ={ 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class _...
696
1
'''simple docstring''' import unittest from knapsack import knapsack as k class _UpperCamelCase ( unittest.TestCase ): def UpperCamelCase__ ( self : List[Any] ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[Any] = 0 __SCREAMING_S...
715
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: int ): if number > 0: raise ValueError("""input must be a negative integer""" ) __SCREAMING_SNAKE_CASE : str = len(bin(_lowerCamelCase )[3:] ) __SCREAMING_SNAKE_CASE : Any = bin(abs(_lowerCamel...
178
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case_ : List[str] = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenizatio...
595
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, ...
57
0
def __UpperCAmelCase ( ) -> Optional[int]: """simple docstring""" _a : Dict = [] _a : List[Any] = 1 while len(__a ) < 1E6: constant.append(str(__a ) ) i += 1 _a : List[str] = ''''''.join(__a ) ...
578
def __UpperCAmelCase ( __a : int = 2_000_000 ) -> int: """simple docstring""" _a : List[str] = [0 for i in range(n + 1 )] _a : Tuple = 1 _a : Tuple = 1 for i in range(2 ,int(n**0.5 ) + 1 ): if primality_...
578
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor,...
289
"""simple docstring""" import collections import importlib.util import os import re from pathlib import Path _lowerCAmelCase : Dict = "src/transformers" # Matches is_xxx_available() _lowerCAmelCase : List[Any] = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _impor...
289
1
# 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 just for tests from os...
703
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_avail...
205
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""", } class a__ ...
77
"""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 ): '''simple docstring''' SCREAMING_SNAKE_CASE_ : A...
247
0
'''simple docstring''' import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
245
'''simple docstring''' from collections.abc import Callable def UpperCamelCase ( a , a , a ) -> float: '''simple docstring''' __magic_name__ = a __magic_name__ = b if function(a ) == 0: # one of the a or b is a root for the function ...
245
1
from __future__ import annotations import math def A__ ( __A : int ) ->bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ...
184
def A__ ( __A : str , __A : str ) ->str: if not (isinstance(__A , __A ) and isinstance(__A , __A )): raise ValueError('''longest_common_substring() takes two strings for inputs''' ) __A =len(__A ) __A =len(__A ) _...
184
1
"""simple docstring""" def UpperCamelCase_ ( lowerCamelCase : Any ) -> List[str]: """simple docstring""" __magic_name__ : Union[str, Any] = len(lowerCamelCase ) __magic_name__ : Dict = sum(lowerCamelCase ) __magic_name__ ...
147
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar A = TypeVar("""T""") A = TypeVar("""U""") class _UpperCamelCase ( Generic[T, U] ): """simple docstring""" def __init__( self : Any , snake_case : ...
147
1
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : Optional[Any]=2_81_23 ) -> str: '''simple docstring''' UpperCAmelCase_ = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for...
78
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import floa...
439
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_M...
708
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def SCREAMING_SNAKE_CASE( __UpperCamelCase ) -> Dict: if "cls_token" in name: a__ : Union[str, Any] = name.replace("cls_toke...
207
0
'''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 transformer...
150
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def __lowercase (_lowercase, _lowercase, _lowercase, _lowercase, _lowercase = None, _lowercase = None, _lowercase...
150
1
def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ =(num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def UpperCAmelCase_ ( ): print(sum_of_s...
588
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ =nn....
588
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 __A = '▁' __A = {'vocab_file': 'spiece.model'} __A = {...
586
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from datas...
456
0
def A ( _UpperCAmelCase : List[Any] , _UpperCAmelCase : Tuple ) -> int: '''simple docstring''' while a != 0: _UpperCAmelCase , _UpperCAmelCase = b % a, a return b def A ( _UpperCAmelCase : Dict , _U...
712
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet impo...
639
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Optional[int] ...
4
import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : List[Any]...
141
0
'''simple docstring''' import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # pytho...
716
'''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 f...
539
0
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class a_ ( unittest.TestCase ): '''simple docstring''' def _lowercase ( self ) -> i...
318
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a_ ( unittest.TestC...
318
1
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __lowerCamelCase ( snake_case__ ,snake_case__=7 ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE = None if token is not None: ...
702
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky...
569
0
"""simple docstring""" class UpperCAmelCase_ : """simple docstring""" def __init__( self : str , a_ : Tuple )-> List[str]: """simple docstring""" UpperCAmelCase_ : Optional[Any] = val UpperCAmelCase_ : List[str] = ...
470
"""simple docstring""" def A_ ( lowercase ) -> None: """simple docstring""" UpperCAmelCase_ : Union[str, Any] = generate_pascal_triangle(lowercase ) for row_idx in range(lowercase ): # Print left spaces for _ in range(num_r...
470
1
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME A = ["""small""", """medium""", """large"""] A = """lm_head.decoder.weight""" A = """lm_head.weight""" def _UpperCamelCase ( UpperCamelCase , UpperCamelCas...
487
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase , UpperCamelCase = False ) -> bool: """simple docstring""" 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 ...
487
1
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def UpperCamelCase ( lowercase_ : Tuple , lowercase_ : Union[str, Any] , lowercase_ : Optional[int] , lowercase_ : Dict ) -> Optional[Any]: '''s...
72
'''simple docstring''' from __future__ import annotations import time import numpy as np _UpperCAmelCase : int = [8, 5, 9, 7] _UpperCAmelCase : List[str] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] _UpperCAmelCase : Union[str, Any] = [ [3, 2, 1, 4...
72
1
"""simple docstring""" import math class lowerCAmelCase_ : '''simple docstring''' def __init__( self , snake_case_=0 ) -> List[Any]: # a graph with Node 0,1,...,N-1 __lowerCAmelCase = n __lowerCAmelCa...
718
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHI...
573
0
"""simple docstring""" from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def snake_case ( A__ ): return getitem, k def snake_case ( A__ ,A__ ): return setitem, k, v def snake_case ( A__ ): return delitem...
95
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_o...
328
0
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
118
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from ut...
118
1
from ... import PretrainedConfig lowerCamelCase : List[str] = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class A( __lowercase ): '''simple docstring''' UpperCamelCase = NEZHA_PRE...
70
'''simple docstring''' import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow __UpperCamelCase = logging.getLogger() ...
26
0
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPooli...
594
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.default...
594
1
'''simple docstring''' import os from typing import Dict, List, Tuple, TypeVar, Union snake_case = TypeVar('''T''') snake_case = Union[List[T], Tuple[T, ...]] snake_case = Union[T, List[T], Dict[str, T]] snake_case = Union[str, bytes, os.PathLike]
309
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class SCREAMING_SNAKE_CASE ( __a ): """simple docstring""" __A = "" __A = ( None # protocol passed in...
309
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''', '''funnel-transformer/small-b...
336
from __future__ import annotations class A__ : def __init__( self , lowerCamelCase ) -> None: """simple docstring""" __magic_name__ : List[str] = data __magic_name__ : Node | None = ...
336
1
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils impo...
335
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case : Optional[Any] = { '''configuration_roberta_prelayernorm''': [ '''ROBERTA_PRELAYERNORM_PRETRAINED_CON...
335
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class lowerCAmelCase__ ...
492
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretra...
492
1
'''simple docstring''' UpperCAmelCase_ : str = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': 'ABBAA'...
533
import os from collections.abc import Iterator def _SCREAMING_SNAKE_CASE ( snake_case = "." ) -> Iterator[str]: for dir_path, dir_names, filenames in os.walk(snake_case ): _UpperCAmelCase = [d for d in dir_names if d != """scripts""" and d[0...
518
0
'''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, ) if is_sentencepiece_available(): from ..ta.tok...
718
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import...
13
0
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring'''...
59
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Any = logging.get_logger(__name__) __lowerCamelCase : Optional[int] = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/mai...
416
0
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _UpperCamelCase ( UpperCamelCase__ ): # A local function to see if a dot lands in the circle. def is_in_circle(UpperCame...
113
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _UpperCamelCase ( UpperCamelCase__ ): # A local function to see if a dot lands in the circle. def is_in_circle(UpperCame...
113
1
"""simple docstring""" import torch def A ( ): """simple docstring""" if torch.cuda.is_available(): snake_case_ :List[str] = torch.cuda.device_count() else: snake_case_ :str = 0 print(F'''Successfully ran on {num_gpus} GPUs''' ...
584
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCA...
584
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 ( ...
204
'''simple docstring''' import requests from bsa import BeautifulSoup def __A ( UpperCAmelCase ,UpperCAmelCase ) -> str: '''simple docstring''' _UpperCamelCase : Dict = BeautifulSoup(requests.get(UpperCAmelCase ,params=UpperCAmelCase ...
204
1
"""simple docstring""" class __lowerCamelCase : def __init__(self ): '''simple docstring''' _lowerCAmelCase = 0 _lowerCAmelCase = 0 _lowerCAmelCase = {} def A__ (self , lowerCamelCase ): '...
156
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : str = {} class __lowerCamelCase ( __lowercase ): __UpperCame...
156
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): ...
208
from __future__ import annotations from collections.abc import Sequence from typing import Literal def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> str | Literal[False]: snake_case__ = list(__lowerCAmelCase ) snake_case__ ...
208
1
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transform...
466
# Copyright (c) 2021-, NVIDIA CORPORATION. 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...
257
0
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hub_...
516
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_vision from transformers.utils im...
516
1
import argparse import os import re a__: Any = 'src/transformers/models/auto' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a__: List[str] = re.compile(r'[A-Z_]+_MAPPING(\s+|_[A-Z_]...
190
import math def UpperCamelCase__( UpperCamelCase__ : int )->list: A__ = [True] * n A__ = False A__ = False A__ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): A__ = i * 2 wh...
190
1
from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=lowerCAmelCase): _a = ['''torch''', '''scipy'''] def __init__( self: List[str] , *_lowerCAmelCase: Tuple , **_lowerCAmelCase: str ): r...
453
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils import...
453
1
'''simple docstring''' from collections.abc import Callable import numpy as np def __lowercase ( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase ) -> np.array: '''simple docstring''' _A = int(np.ceil((x_end - xa) / step_size ) ) ...
330
'''simple docstring''' import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import Generati...
330
1
'''simple docstring''' import qiskit def lowercase_ ( lowercase__ , lowercase__ ) ->qiskit.result.counts.Counts: _snake_case: Tuple = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register _snake_case: List[...
703
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase ( __UpperCAmelCase ): _SCREAMING_SNAKE_CASE = "Speech2TextFeatureExtractor" _SCREAMING_SNAKE_CASE = "Speech2...
273
0
"""simple docstring""" # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 t...
657
"""simple docstring""" from ..utils import DummyObject, requires_backends class _lowerCAmelCase ( metaclass=lowerCamelCase ): lowercase_ : Dict = ['''torch''', '''torchsde'''] def __init__( self , *a_ , **a_ ) -> Optional[int]: requires_backends(self ,...
657
1
'''simple docstring''' import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( "T...
329
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
329
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch,...
592
import math def lowerCamelCase__ ( snake_case_ : int ) -> bool: __snake_case = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(snake_case_ ) def lowerCamelCase__ ( snake_case_ : flo...
592
1
'''simple docstring''' import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchS...
216
'''simple docstring''' from collections import deque def __UpperCAmelCase ( A : int ) -> Optional[Any]: UpperCAmelCase_ : Tuple = len(A ) UpperCAmelCase_ : Dict = deque() UpperCAmelCase_ : Optional[Any] = [False for _ in r...
216
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy snake_case = log...
103
import torch from torch import nn class A__ ( nn.Module ): '''simple docstring''' def __init__( self : List[str] , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CA...
280
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature...
631
'''simple docstring''' import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _A : Union[str, Any] =False class _lowercase ( ...
631
1
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase_ = get_tests_dir('fixtu...
560
"""simple docstring""" import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models...
560
1
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase_ ( lowerCamelCase_ ): """simple docstring""" def __init__( self , lowerCamelCase ...
435
'''simple docstring''' 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 A__ ( ): '''simple doc...
435
1
from dataclasses import dataclass from typing import 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 .modeling_utils import ModelMixin from .vae import Decoder, Deco...
304
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer lowercase_ : Union[str, Any] = logging.get_logger(__name__) lowercase_ : Dict ...
304
1
'''simple docstring''' from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _co...
717
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def _lowerCamelCase (__lowerCamelCase : Any ) -> Optional[int]: a__ = [ "encoder.version", "deco...
289
0
from string import ascii_lowercase, ascii_uppercase def lowerCAmelCase__ ( a__: str ) -> str: '''simple docstring''' if not sentence: return "" _UpperCAmelCase = dict(zip(a__ , a__ ) ) return lower_to_upper.get(sente...
618
from typing import Any def lowerCAmelCase__ ( a__: list , a__: list , a__: dict , a__: dict , a__: dict , ) -> list: '''simple docstring''' _validation( a__ , a__ , a__ , a__ , ...
618
1
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
701
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenizat...
537
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available A = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasT...
449
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTI...
449
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 A (SCREAMING_SNAKE_CASE ): '''simple...
247
# 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 r...
247
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging lowerCamelCase =logging.get_logger(__name__) class _lowerCam...
285
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase ={ "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available(): raise ...
285
1
'''simple docstring''' def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_) -> Optional[int]: global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: UpperCamelCase__ ...
6
'''simple docstring''' def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_) -> list[str]: return [sentence[i : i + ngram_size] for i in range(len(lowerCamelCase_) - ngram_size + 1)] if __name__ == "__main__": from doctest import testmod testmod(...
6
1
'''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 UpperCAmelCase : '''simple docstring''' def __init...
42
'''simple docstring''' 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 OptionalDepend...
5
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _lowerCAmelC...
713
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def UpperCAmelCase ( a_ , a_=1 ) -> str: """simple docstring""" if n_shave_prefix_segments >= 0: ...
385
0
'''simple docstring''' from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_visio...
199
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a: Any = logging.get_logger(__name__) __a: Dict = { '''vocab_file''': '''vocab.json''', '''merge...
108
0
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers im...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
1
import tensorflow as tf from ...tf_utils import shape_list class lowerCamelCase (tf.keras.layers.Layer ): """simple docstring""" def __init__( self : str, _UpperCAmelCase : List[Any], _UpperCAmelCase : List[str], _UpperCAmelCa...
663
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _lowerCamelCase : List[str] = 2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
663
1
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def a__ ( lowerCAmelCase__ ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , "parameters.json" ) ...
14
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def a__ ( lowerCAmelCase__ ): UpperCAmelCase_ = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementati...
14
1
'''simple docstring''' import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME d...
26
'''simple docstring''' def _a ( _lowerCamelCase = 100 ) -> int: """simple docstring""" __snake_case : Any = n * (n + 1) * (2 * n + 1) / 6 __snake_case : List[Any] = (n * (n + 1) / 2) ** 2 return int(s...
26
1
import unittest from transformers import AutoTokenizer, FalconConfig, 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 Mode...
715
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_utils import require_m...
106
0
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('''.''') def UpperCAmelCase ( snake_case : Any ): _lowerCAmelCase:Dict = test_fi...
227
"""simple docstring""" import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # n...
227
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowercase (snake_case__ : int , snake_case__ : List[Any] , snake_case__ : Tuple ) -> int: '''simple docstri...
703
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase (snake_case__ : dict , snake_case__ : str , snake_case__ : set , snake_case__ : set , snake_case__ : dict , snake_c...
529
0
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObject...
259
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def a_ ( ) -> Optional[int]: _snake_case , _snake_case = 9, 14 # noqa: F841 _snake_case = [ [0, 1, 4], [0, 7, 8], [1, 2, 8]...
686
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logg...
555
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor UpperCAmelCase = logging.get_logger(__name__) class a ( __magic_name__ ): def __init__( self : Union[str, Any], *SCREAMING_SNAKE_CAS...
555
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import l...
47
from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNo...
47
1
import pytest import datasets # Import fixture modules as plugins SCREAMING_SNAKE_CASE__ = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : List[Any] , SCREAMING_SNAKE_CASE : Tuple ) -...
688
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAK...
688
1
'''simple docstring''' import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokeni...
370
'''simple docstring''' from __future__ import annotations import math def snake_case__ ( _A: int ) -> list[int]: '''simple docstring''' if num <= 0: lowerCAmelCase = f"{num}: Invalid input, please enter a positive integer." raise ValueError(_A ) low...
370
1
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): while b: lowercase__ , lowercase__ = b, a % b return a def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): return a if b == 0 else euclidean_gcd_recursive(SCREAMING_SNA...
714
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .toke...
37
0
from manim import * class SCREAMING_SNAKE_CASE (UpperCAmelCase ): def SCREAMING_SNAKE_CASE_ ( self : Tuple )-> Optional[int]: """simple docstring""" lowercase__ = Rectangle(height=0.5 , width=0.5 ) lowerca...
235
import requests lowercase_ = """YOUR API KEY""" def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = giphy_api_key ) -> list: lowercase__ = '+'.join(query.split() ) lowercase__ = F"""https://api.giphy.co...
235
1
from ..utils import DummyObject, requires_backends class _a ( metaclass=UpperCamelCase__ ): _lowercase : Any = ['''note_seq'''] def __init__( self: List[str] , *UpperCamelCase_: Optional[int] , **UpperCamelCase_: Tuple ) -> Lis...
429
from typing import Dict, List, Optional, Tuple, 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_di...
429
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _lowerCAmelCase ( lowerCamelCase ): @staticmethod @abstractmethod def _a ( a_ ) -> str: raise NotImplementedError() @abstractmethod def _a ( ...
657
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _lowerCAmelCase ( unittest.TestCase ): def _a ( self ) -> Optional[Any]: _Uppe...
657
1
from ... import PretrainedConfig UpperCamelCase__ ={ 'sijunhe/nezha-cn-base': 'https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json', } class lowerCAmelCase__( __lowercase ): '''simple docstring''' __snake_case = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MA...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ ={ 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_available(): raise OptionalDependencyNotAva...
381
0
'''simple docstring''' import flax.linen as nn import jax import jax.numpy as jnp class SCREAMING_SNAKE_CASE ( nn.Module ): snake_case__ = 42 snake_case__ = jnp.floataa def SCREAMING_SNAKE_CASE ( self : st...
466
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available():...
466
1
"""simple docstring""" from math import ceil def lowercase (_snake_case ,_snake_case ) -> Any: '''simple docstring''' __UpperCamelCase = list(range(0 ,__snake_case ) ) __UpperCamelCase = [item for sublist in list(device_map.values() )...
707
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from ...
228
0
lowerCAmelCase__ = { 0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f', } def __lowercase ( _UpperCAmelCase ) -> str: '''simple do...
321
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logging ...
321
1
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( ...
707
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffu...
167
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json', # See all Cvt models at https://hug...
320
'''simple docstring''' A = [ 'Audio', 'Array2D', 'Array3D', 'Array4D', 'Array5D', 'ClassLabel', 'Features', 'Sequence', 'Value', 'Image', 'Translation', 'TranslationVariableLanguages', ] from .audio import Audio from .features impor...
320
1
import numpy as np def snake_case_ (_a : np.ndarray ): return 1 / (1 + np.exp(-vector )) def snake_case_ (_a : np.ndarray ): return vector * sigmoid(_a ) if __name__ == "__main__": import doctest doctest.testmod()
701
'''simple docstring''' def snake_case_ (_a : list[list[int]] , _a : int , _a : int , _a : list[int] ): # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False ...
358
0
'''simple docstring''' def __snake_case ( SCREAMING_SNAKE_CASE_ : int ) -> Optional[int]: """simple docstring""" UpperCAmelCase = len(_A ) for i in range(length - 1 ): UpperCAmelCase = i for k in range(i + 1 , _A ): ...
51
"""simple docstring""" import string from math import logaa def A ( _A, _A ): """simple docstring""" snake_case_ :Union[str, Any] = document.translate( str.maketrans("", "", string.punctuation ) ).replace("\n", "" ) snake_case_ :Tuple ...
584
0
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ....
707
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultip...
156
0
"""simple docstring""" import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table i...
95
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase__ :Tuple = logging.get_logger(__name__) lowercase__ :List[Any] = { 'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc...
522
0
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from acceler...
713
'''simple docstring''' from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand UpperCamelCase =logging.get_logger(__name__) # pylint: disable=invalid-name def ...
543
0
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
495
'''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, ...
495
1
from scipy.stats import pearsonr import datasets lowerCamelCase : Optional[Any] = ''' Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the a...
290
# 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 ap...
290
1