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
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging loggin...
569
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers....
569
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : List[Any] = logging.get_logger(__name__) _UpperCAmelCase : List[str] = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "...
453
def UpperCAmelCase__ ( lowerCamelCase ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 lowercase :str = 1 lowercase :Tuple = 1 while repunit: lowercase :Dict = (10 * repunit + 1) % divisor repunit_index += 1 return repunit_index de...
453
1
'''simple docstring''' from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..models...
507
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class a__ ( nn.Module ): def __init__(self : Union[str, Any], __UpperCAmelCase : int = 16, __UpperCAmelCase : int = 88, ...
507
1
from __future__ import annotations from typing import Any class a__ : def __init__( self , UpperCAmelCase = 6 ) -> None: __a = None __a = None self.create_linked_list(UpperCAmelCase ) def __SCREAMING_SNAKE_CASE (...
246
from __future__ import annotations lowerCamelCase_ : List[Any] = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"...
246
1
"""simple docstring""" def lowercase_ ( _lowercase : int = 10**12 ): '''simple docstring''' UpperCAmelCase : Union[str, Any] = 1 UpperCAmelCase : List[str] = 0 UpperCAmelCase : Dict = 1 UpperCAmelCase : Union[str, An...
595
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowercase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: lowercase = [...
272
0
import os import time import numpy as np import onnxruntime as ort a = '''1''' a = '''0''' a = '''1''' a = ort.SessionOptions() a = ort.GraphOptimizationLevel.ORT_DISABLE_ALL print('Create inference session...') a = ['''TensorrtExecutionProvider''', '''CU...
709
import cva import numpy as np class UpperCamelCase__ : def __init__( self : List[str] , UpperCamelCase__ : float , UpperCamelCase__ : int ): '''simple docstring''' if k in (0.04, 0.06): lowercas...
650
0
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functiona...
73
'''simple docstring''' from math import factorial def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> float: if successes > trials: raise ValueError('''successes must be lower or equal to trials''' ) if trials < 0 or successes < 0: ...
75
0
def A ( lowercase = 4_000_000 ) -> int: '''simple docstring''' UpperCamelCase = [] UpperCamelCase , UpperCamelCase = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(lowercase ) UpperCamelCase , UpperCamelCase = b, a + b return sum(lower...
714
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets _UpperCAmelCase : Any = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n author={Wang, Alex and ...
3
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE_ = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfi...
582
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # See all BioG...
582
1
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __lowerCAmelCase ( snake_case : str = "isbn/0140328726" ) -> dict: __lowerCamelCase: Tuple = olid.strip().strip("""/""" ) # Remove leadin...
715
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_numpy, slow, tor...
189
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import Rea...
126
'''simple docstring''' import os from datetime import datetime as dt from github import Github _A: Any = [ """good first issue""", """feature request""", """wip""", ] def _lowerCAmelCase ( )-> Optional[int]: __UpperCAmelCase = Github(os.environ['GITHUB_TOKEN...
126
1
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerB...
721
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_loggin...
635
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase__ : Union[str, Any] = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokeniza...
105
def lowerCAmelCase_ ( _lowercase : list , _lowercase : int , _lowercase : int = 0 , _lowercase : int = 0) -> int: """simple docstring""" a__ : str = right or len(_lowercase) - 1 if left > right: return -1 elif list_dat...
136
0
"""simple docstring""" import string from math import logaa def _UpperCamelCase ( _A , _A ) -> int: """simple docstring""" _UpperCAmelCase = document.translate( str.maketrans("""""" , """""" , string.punctuation ) ...
713
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...
19
0
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , ): """simple docstring""" UpperCAmelCase = len(__UpperCAmelCase ) # If row is equal to the size of the bo...
333
'''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 acc...
501
0
"""simple docstring""" def UpperCAmelCase__ ( A__ , A__ ) -> bool: """simple docstring""" lowerCamelCase__ = len(A__ ) lowerCamelCase__ = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by not ...
274
"""simple docstring""" def UpperCAmelCase__ ( A__ ) -> list[int]: """simple docstring""" if length <= 0 or not isinstance(A__ , A__ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(A__ )] if __name__ == "__main__": ...
274
1
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def __a ( A__ : Any ): SCREAMING_SNAKE_CASE ...
16
from collections.abc import Callable import numpy as np def __a ( A__ : Callable , A__ : float , A__ : float , A__ : float , A__ : float ): SCREAMING_SNAKE_CASE = int(np.ceil((x_end - xa) / step_size ) ) SCREAMING_SNAKE_CASE ...
16
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A__ : Any = logging.get_logger(__name__) A__ : str = { "hustvl/yolos-s...
705
from math import factorial, radians def _lowercase ( a_ : float ,a_ : int = 1_8 ,a_ : int = 1_0 ) -> float: '''simple docstring''' __magic_name__ = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees ...
184
0
import os import string import sys a_ = 1 << 8 a_ = { """tab""": ord("""\t"""), """newline""": ord("""\r"""), """esc""": 27, """up""": 65 + ARROW_KEY_FLAG, """down""": 66 + ARROW_KEY_FLAG, """right""": 67 + ARROW_KEY_FLAG, """left""": 68 + ARROW_KEY_FLAG, ...
175
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available():...
296
0
'''simple docstring''' import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib A_ ...
709
'''simple docstring''' import random def A_ ( snake_case , snake_case , snake_case = False ): SCREAMING_SNAKE_CASE:dict = {i: [] for i in range(snake_case )} # if probability is greater or equal than 1, then generate a complete graph if probability >...
465
0
# 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.path import join ...
408
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
243
0
import collections import importlib.util import os import re from pathlib import Path _SCREAMING_SNAKE_CASE = """src/transformers""" # Matches is_xxx_available() _SCREAMING_SNAKE_CASE = re.compile(R"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} _S...
534
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( __a , __a ): # Load...
534
1
'''simple docstring''' lowerCAmelCase : Tuple ='''Input must be a string of 8 numbers plus letter''' lowerCAmelCase : Optional[Any] ='''TRWAGMYFPDXBNJZSQVHLCKE''' def UpperCAmelCase_ ( __lowerCamelCase : str ): if not isinstance(__lowerCamelCase ,__lowerCame...
172
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int ): if number > 0: raise ValueError("input must be a negative integer" ) lowercase_ :Optional[Any] = len(bin(__lowerCamelCase )[3:] ) lowercase_ :Optional[int] ...
172
1
'''simple docstring''' import os def A (__lowerCamelCase :Dict ): _lowerCAmelCase = len(grid[0] ) _lowerCAmelCase = len(__lowerCamelCase ) _lowerCAmelCase = 0 _lowerCAmelCase = 0 _lowerCAmelCase = 0 # Check vertically, hor...
162
'''simple docstring''' def A (__lowerCamelCase :int ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): _lowerCAmelCase = f'Input value of [number={number}] must be an integer' raise TypeError(__lowerCamelCase ) if number < 1: _lowerCAmelC...
162
1
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepI...
261
'''simple docstring''' def _A ( snake_case__ : list[int] , snake_case__ : list[int] ): snake_case__ : Tuple = len(snake_case__ ) print('''The following activities are selected:''' ) # The first activity is always selected snake_case__ : Optional[Any] ...
261
1
import re import string import numpy as np import datasets _lowerCamelCase : Tuple = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" _lowerCamelCase :...
703
from collections.abc import Generator def _a ( ) -> Generator[int, None, None]: '''simple docstring''' SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ : Any = 0, 1 while True: SCREAMING_SNAKE_CASE__ ,SCREA...
157
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass class ...
162
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversationa...
162
1
import glob import os import random from string import ascii_lowercase, digits import cva UpperCAmelCase__ : int = '' UpperCAmelCase__ : List[str] = '' UpperCAmelCase__ : List[str] = '' UpperCAmelCase__ : List[str] = 1 # (0 is vertical, 1 is horizontal) def _A ...
710
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(): import torch ...
416
0
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> list: '''simple docstring''' if len(lowercase_ ) == 0: return [] __UpperCAmelCase , __UpperCAmelCase : Optional[int] = min(lowercase_ ),...
462
from __future__ import annotations import requests lowerCAmelCase = set( """approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categories created_utc down...
462
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase : Any = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvai...
47
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers i...
47
1
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers...
66
"""simple docstring""" import functools def A ( _A, _A ): """simple docstring""" snake_case_ :Optional[Any] = len(_A ) snake_case_ :Optional[int] = len(_A ) @functools.cache def min_distance(_A, _A ) -> int: # if firs...
584
0
"""simple docstring""" import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def __lowercase ( _a , _a , _a ): snake_case_ : Tuple = AutoConfig.from_pretrained(_a ) snake_case_ : Tuple = FlaxAutoModelF...
485
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transform...
485
1
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _UpperCAmelCase : Union[str, Any] = (720, 1280) # Height, Width _UpperCAmelCase : str = (0.4, 0.6) # if height or width lower than this scale, drop it. ...
683
'''simple docstring''' 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 UpperCA...
683
1
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_params...
648
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificat...
648
1
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @requir...
206
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _UpperCamelCase : Union[str, Any] ={'UserAgent': UserAgent().random} def a__ (__lowercase :Optional[Any] ) -> dict: _A : str = ...
206
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowercase__ ( unittest.TestCase ): def _UpperCAmelCase ( self : str ): """simple docstring""" UpperCAmelCase__ = [...
277
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor A = logging.get_logger(__name__) class lowercase__ ( __SCREAMING_SNAKE_CASE ): def __init__( self : Union[str, Any] , *_lowercase : Any , *...
277
1
def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): return base * power(__lowercase , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print("Raise base to the power of exponent using recursion...") UpperCAmelCase_ : Dict = int(inp...
21
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtracto...
558
0
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def _SCREAMING_SNAKE_CASE ( ): print("""Making key files...""" ) make_key_files("""rsa""" , 1024 ) print("""Ke...
572
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( snake_case_ ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 _lowercase = 1 _lowercase = 1 while repunit: _lowercase = (10 * repunit + 1) % divisor repunit_index += 1 return repunit_index def _SCREAMING_SN...
572
1
'''simple docstring''' from manim import * class lowerCAmelCase ( UpperCamelCase_ ): def _A ( self : Dict ): '''simple docstring''' lowerCAmelCase__ : Optional[int] = Rectangle(height=0.5 , width=0.5 ) lowerCAmelCase__ : List[Any] = Rectangle(he...
378
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py snake_case = """.""" if __name__ == "__main__": snake_case = os.path.join(REPO_PATH, """utils/documentation_tes...
378
1
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_...
460
'''simple docstring''' def _snake_case ( A_ : list ): """simple docstring""" if len(A_ ) <= 1: return lst a_ : Any = 1 while i < len(A_ ): if lst[i - 1] <= lst[i]: i += 1 else: a_ , a_ : int = ...
460
1
"""simple docstring""" import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_availab...
65
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu...
521
0
# 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...
86
import math import unittest from transformers import BioGptConfig, 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 ModelTest...
86
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ...
27
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be c...
27
1
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig if i...
721
from __future__ import annotations def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" if b == 0: return (1, 0) ((__lowercase) , (__lowercase)) = extended_euclid(lowercase , a % b ) __lowercase = ...
522
0
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tests_di...
343
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ) -> Dict: '''simple docstring''' if index == r: for j in range(_UpperCAmelCase ): print(data[j], end=' ' ) ...
343
1
from timeit import timeit def __UpperCamelCase ( lowerCAmelCase__ : int ): if number < 0: raise ValueError('''the value of input must not be negative''' ) __a : int = 0 while number: number &= number - 1 result += 1 return result def __UpperC...
326
import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __UpperCamelCase ( lowerCAmelCase__ : ...
326
1
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> List[Any]: _snake_case = int(lowerCAmelCase_ ) assert noofclusters < len(lowerCAmelCase_ ) # F...
103
from collections.abc import Iterable from typing import Any class A : def __init__( self : Dict , lowercase_ : int | None = None ) -> int: """simple docstring""" _lowerCamelCase : List[Any] =value _lowerCamelCase : ...
464
0
'''simple docstring''' 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 OptionalDependencyNotAva...
609
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : List[Any] = { "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Lx...
609
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ : Dict =logging.get_logger(__name__) lowerCAmelCase__ : Any ={ '''facebook/convnextv2-tiny-1k...
148
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : List[str] =logging.get_logger(__name__) lowerCAmelCase__ : List[Any] ={ '''vocab_file''': '''vocab...
148
1
import pytest __A : Any = """__dummy_dataset1__""" __A : List[str] = """ import json import os import datasets REPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\" URLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", \"validatio...
450
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem __A : Tuple = importlib.util.find_spec("""s3fs""") is not None if _has_safs: from .safilesystem import S...
450
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCamelCase__ ( A__ ): @staticmethod @abstractmethod def lowerCamelCase_ ( __a : ArgumentParser ): '''simple docstring''' r...
306
def __lowerCAmelCase ( _UpperCamelCase = 2000000 ) -> int: '''simple docstring''' lowerCamelCase__: Tuple = [0 for i in range(n + 1 )] lowerCamelCase__: Optional[Any] = 1 lowerCamelCase__: List[str] = 1 ...
306
1
from __future__ import annotations from collections import Counter from random import random class _SCREAMING_SNAKE_CASE : def __init__(self): '''simple docstring''' __UpperCAmelCase ={} def A__ (self , UpperCAmelCase): '''simple docstring''' ...
718
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_ = { 'configuration_albert': ['ALBERT_PRETRAINE...
142
0
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() UpperCamelCase__ = logging.get_logger('''transformers.models.speecht5''') def a__ ( lowerCAmelCase__...
75
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __lowerCamelCase = logg...
317
0
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowerCamelCase__ = logging.get_logger(__n...
226
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils impor...
226
1
"""simple docstring""" import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowerCAmelCase_ ( SCREAMING_SNA...
179
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionCon...
293
0
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _lowerCamelCase ( ): lowercase__ : Union[str, Any] = ArgumentParser( description=( """PyTo...
704
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer __snake_case = logging.get_logger(__name__) __...
128
0
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from tra...
42
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _snake_case ( __snake_case ): _UpperCame...
71
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowerCAmelCase = {"configuration_unispeech": ["UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP", "UniSpeechConfig"]} try: if not is_to...
71
1
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _UpperCAmelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _UpperCAmelCase : list[int] = ...
107
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> List[str]: """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(__lowerCAmelCase , int(b / 2 ) ) * actual_power(__lowerCAmelCase , int(b / 2 ) ) els...
252
0
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.u...
250
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch a_ :Optional[Any] ...
250
1
"""simple docstring""" def lowerCAmelCase_( lowercase_ : str , lowercase_ : str ) -> float: def get_matched_characters(lowercase_ : str , lowercase_ : str ) -> str: _lowerCamelCase = [] _lowerCamelCase = min(len(_stra ) , len(_st...
661
"""simple docstring""" def lowerCAmelCase_( lowercase_ : int = 10 ) -> str: if not isinstance(lowercase_ , lowercase_ ) or n < 0: raise ValueError('''Invalid input''' ) _lowerCamelCase = 10**n _lowerCamelCase = 2_84_33 * (pow(2 , 7_83_04_57 ,...
661
1
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def lowerCamelCase ( _UpperCamelCase : List[str] ) -> List[Any]: '''simple docstring''' __UpperCAmelCase : Optional[i...
299
"""simple docstring""" from __future__ import annotations import queue class lowerCamelCase__ : """simple docstring""" def __init__( self : str , UpperCamelCase : List[Any] ): '''simple docstring''' __UpperCAmelCase : Any ...
299
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension ...
608
"""simple docstring""" import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration __lowerCamelCase = [ # tf -> hf ("/", "."), ("layer_", "layers."), ("kerne...
608
1
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 UpperCamelCase ( unitte...
110
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class UpperCamelCase ( unittest.TestCase ): """simple docstring""" snake_case = JukeboxTokenizer snake_case = { "artist": "Zac Brown Band", "genres": "Coun...
110
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass _lowerCAmelCase : Tuple = (3, 9, -11, 0, 7, 5, 1, -1) _lowerCAmelCase : Dict = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __magic_n...
242
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __magic_name__ ( lowerCAmelCase_ ): SCREAMING_SNAKE_CAS...
242
1
'''simple docstring''' from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase__ ( lowercase__ ): '''simple docstring''' def __init__( self , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_...
700
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil A_ = 1_00 A_ = set(range(3, NUM_PRIMES, 2)) primes.add(2) A_ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: ...
123
0
'''simple docstring''' import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) class UpperCAmelCase ( lowercase...
404
'''simple docstring''' class UpperCAmelCase : """simple docstring""" def __init__( self : Tuple ) -> List[Any]: _UpperCamelCase ='''''' _UpperCamelCase ='''''' _UpperCamelCase =[] def UpperCamelCase__ ( self : ...
404
1
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHea...
708
from __future__ import annotations from functools import lru_cache from math import ceil lowerCamelCase__ = 1_00 lowerCamelCase__ = set(range(3, NUM_PRIMES, 2)) primes.add(2) lowerCamelCase__ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: ...
226
0
'''simple docstring''' 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...
440
"""simple docstring""" from typing import Any def lowercase ( lowerCAmelCase__ : list , lowerCAmelCase__ : list , lowerCAmelCase__ : dict , lowerCAmelCase__ : dict , lowerCAmelCase__ : dict , ) -> list: _validation( l...
695
0
from collections import Counter from timeit import timeit def lowerCamelCase_ ( _lowercase = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def lowerCamelCase_ ( _lowercas...
704
from __future__ import annotations def lowerCamelCase_ ( _lowercase , _lowercase , _lowercase ) -> float: if days_between_payments <= 0: raise ValueError("days_between_payments must be > 0" ) if daily_interest_rate < 0: raise ValueError("daily_interes...
387
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase = { 'configur...
466
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __lowerCAmelCase = { 'sample_size': 32, 'in_channels': 3, 'out_channels': 3, ...
466
1
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __snake_case ( __A): '''simple docstring''' UpperCamelCase__ : Any = """ClapFeatureExtractor""" UpperCamelCase__ : Any = ("""Ro...
709
import os from datetime import datetime as dt from github import Github UpperCAmelCase = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ] def ...
351
0
"""simple docstring""" import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration __A : Any = { '''tiny.en''': '''h...
231
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
231
1
"""simple docstring""" def _lowerCAmelCase ( ): '''simple docstring''' for n in range(1 , 1_0_0_0_0_0_0 ): yield n * (n + 1) // 2 def _lowerCAmelCase ( __lowerCamelCase:Dict ): '''simple docstring''' __magic_na...
468
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import Att...
468
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _snake_case ( snake_case__ : BertModel , snake_case__ : str , snake_case__ : str ): A = ('dense.weight', 'attention.self.query', 'atte...
91
'''simple docstring''' 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 .te...
294
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 TFCamembertModel ...
467
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class a ( UpperCAmelCase ): _lower...
467
1
"""simple docstring""" from __future__ import annotations import time UpperCAmelCase = list[tuple[int, int]] UpperCAmelCase = [ [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...
420
"""simple docstring""" def lowercase ( a__ : float , a__ : int ) -> float: if digit_amount > 0: return round(number - int(a__ ) , a__ ) return number - int(a__ ) if __name__ == "__main__": print(decimal_isolate(1.53, 0)) print(decimal_isolate(35.3_45...
420
1
def lowerCamelCase__ ( ) -> List[Any]: """simple docstring""" a__ :Any = [] a__ :Union[str, Any] = 1 while len(a ) < 1e6: constant.append(str(a ) ) i += 1 a__ :str = "".join(a ) return ( int(constan...
702
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.json''', # See all SE...
373
0
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import float...
555
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration a : int = 5_0_0_0_0_0 a , a : Union[str, Any] = os.path.split(__file__) a : Dict = os.path.joi...
555
1
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...
720
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transforme...
45
0
'''simple docstring''' import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed f...
325
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum ...
325
1
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_...
17
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py __SCREAMING_SNAKE_CASE = """.""" if __name__ == "__main__": __SCREAMING_SNAKE_CASE = os.path.join(REPO_PATH, """utils...
17
1
from __future__ import annotations from dataclasses import dataclass @dataclass class lowerCAmelCase_ : UpperCAmelCase = 42 UpperCAmelCase = None UpperCAmelCase = None def _snake_case ( __snake_case ): # Validation def is_valid_tree(_...
10
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceC...
453
0
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging __lowerCamelCase = logging.get_logger(__name__) class UpperCamelCase_ : lowercase = None @experimental def UpperCamelCase__ ( Uppe...
307
from maths.prime_factors import prime_factors def UpperCamelCase__ ( UpperCAmelCase ) -> int: """simple docstring""" if not isinstance(UpperCAmelCase , UpperCAmelCase ): _a : Optional[Any] = F'Input value of [number={number}...
307
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docst...
418
'''simple docstring''' from heapq import heappop, heappush import numpy as np def SCREAMING_SNAKE_CASE_ ( __A : np.ndarray , __A : tuple[int, int] , __A : tuple[int, int] , __A : bool , ) -> tuple[float | int, list[tuple[int, int]]]: _SCREA...
418
1
import random from .binary_exp_mod import bin_exp_mod def A_ ( _lowerCAmelCase , _lowerCAmelCase=1000 ) -> Optional[int]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd UpperCamelCase : Union[str, Any] = n - 1 UpperCamelCase : T...
38
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A__ ( __snake_ca...
38
1
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ = TypeVar('''T''') def UpperCAmelCase__ ( lowerCamelCase_ : int ): return (position - 1) // 2 def UpperCAmelCase__ ( low...
47
'''simple docstring''' import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __lowerCAmelCase : Any =logging.get_logger(__name__) ...
440
0
def __UpperCAmelCase ( a_): snake_case_ = [0] * len(a_) snake_case_ = [] snake_case_ = [] snake_case_ = 0 for values in graph.values(): for i in values: indegree[i] += 1 for i in r...
711
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase = transform...
607
0
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL a : Optional[int] = version.parse(version.parse(torch.__version__).base_version) < ver...
218
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) lowerCAmelCase_ = logging.getLogger(__name__) if __name__ == "__main__": l...
60
0
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ :Dict ): '''simple docstring''' a = len(UpperCAmelCase__ ) a = sum(UpperCAmelCase__ ) a = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(...
708
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from .....
32
0
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import AutoCon...
300
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int , lowerCAmelCase: int ) -> list[list[int]]: _UpperCAmelCase : list[list[int]] = [] create_all_state(1 , lowerCAmelCase , lowerCAmelCase , [] , lowerCAmelCase ) return result ...
300
1
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _U...
704
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_featur...
474
0
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switc...
87
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Any = {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFI...
87
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 lowerCamelCase ( __UpperCAmelCase ): ...
711
import sys _A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452445231617318564030987111217223...
294
0
'''simple docstring''' from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor ...
267
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax im...
267
1
'''simple docstring''' UpperCAmelCase : Dict = { 'meter': 'm', 'kilometer': 'km', 'megametre': 'Mm', 'gigametre': 'Gm', 'terametre': 'Tm', 'petametre': 'Pm', 'exametre': 'Em', 'zettametre': 'Zm', 'yottametre': 'Ym', } # Exponent of the factor(meter) UpperCAmelCase ...
47
'''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 Up...
47
1
"""simple docstring""" __UpperCamelCase : str = 2_5_6 # Modulus to hash a string __UpperCamelCase : Union[str, Any] = 1_0_0_0_0_0_3 def __SCREAMING_SNAKE_CASE ( A_ , A_ ): lowerCAmelCase__ : Dict = len(A_ ) lowerCAmelCase__ : Dict = ...
450
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mo...
450
1
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. snake_case__ : Optional[Any] = 2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst...
707
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor snake_case__ : List[str] = logging.get_logger(__name__) class _a ( UpperCAmelCase__ ): """simple docstring""" def __init__( ...
618
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH...
531
'''simple docstring''' 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...
531
1
from __future__ import annotations def snake_case_ ( __lowercase ): return [ord(__lowercase ) - 9_6 for elem in plain] def snake_case_ ( __lowercase ): return "".join(chr(elem + 9_6 ) for elem in encoded ) def snake_case_ ( ): UpperCAmelCa...
707
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
0