code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
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 ModelTesterMixin, ids_tenso...
284
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Arr...
334
0
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util f...
360
'''simple docstring''' from __future__ import annotations def _A (lowerCAmelCase__ :int ) -> list[int]: '''simple docstring''' _a = 2 _a = [] while i * i <= n: if n % i: i += 1 ...
104
0
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput _lowerCAmelCase : List[Any] = "scheduler_config.json" class _UpperCamelCase ...
169
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase : Optional[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json"...
169
1
import argparse import copy def lowerCAmelCase_ ( __lowerCamelCase ): __snake_case : Tuple = {} with open(__lowerCamelCase ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __s...
134
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _snake_case : Union[str, Any] = datasets.load_iris() _snake_case : Tuple = np.array(data["data"]) _snake_case : int = np.array(data["target"])...
134
1
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class __a (UpperCAmelCase__): '''simple docstring''' def __init__( self , *_a , **_a ) -> List[Any]: """simple docstring""" super().__init__(*_a , **_a ...
132
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _UpperCAmelCase = 5_0_0_0_0_0 _UpperCAmelCase, _UpperCAmelCase = os.path.split(__file__) _UpperCAmelCase = os.path.join(RESULTS...
173
0
from __future__ import annotations import math snake_case_ = '2020.9.26' snake_case_ = 'xcodz-dot, cclaus, dhruvmanila' def lowerCamelCase__ ( snake_case_ : float , snake_case_ : float , snake_case_ : float , snake_case_ :...
238
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): ...
238
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A : Optional[int] = logging.get_logger(__name__) A : Union[str, Any] = { "google/bigbird-roberta-base": "ht...
118
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configura...
118
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : str = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], } try: if not ...
355
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/...
243
0
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : str = logging.get_logger(__name__) UpperCAmelCase : Tuple = { """microsoft/xprophetnet-large-wiki100-cased""": ( ""...
95
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem SCREAMING_SNAKE_CASE_ = importlib.util.find_spec("""s3fs""") is not None if _has_safs: ...
296
0
"""simple docstring""" from collections.abc import Callable import numpy as np def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> str: A__ = int(np.ceil((x_end - xa) / step_size ) ) A__ = ...
358
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels SCREAMING_SNAKE_CASE = object() # For specifying empty leaf dict `{}` SCREAMING_SNAKE_CASE = object() ...
230
0
'''simple docstring''' import json import os import torch from diffusers import UNetaDModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) def lowercase ...
311
'''simple docstring''' import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoToken...
311
1
def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : List[str] = [int(lowerCamelCase__ ) for i in ip_va_address.split("." ) if i.isdigit()] return len(lowerCamelCase__ ) == 4 and all(0 <= int(lowerCamelCase__ ) <= 254 fo...
121
def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : Union[str, Any] = [] lowercase__ : Tuple = [] lowercase__ : Any = { "^": 3, "*": 2, "/": 2, "%": 2, ...
121
1
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
287
'''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...
27
0
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling_tf_...
350
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 ...tokenization_u...
225
0
"""simple docstring""" import sys __lowerCamelCase = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "6689...
221
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, genera...
221
1
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCamelCase = 637_8137.0 UpperCamelCase = 635_6752.31_4245 UpperCamelCase = 637_8137 def _A ( lowerCAmelCase_ : float , lowerCAmelCase_ : floa...
366
from statistics import mean, stdev def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : int = 3 ): """simple docstring""" lowerCAmelCase__ = min(lowerCAmelCase_ ) lowerCAmelCase__ = max(lowerCAmelCase_ ) # ...
221
0
import math import flax.linen as nn import jax.numpy as jnp def a__ ( snake_case , snake_case , snake_case = 1 , snake_case = 1 , snake_case = 1.0E4 , snake_case = False , snake_case = 1.0 , ): """simple docstring""" assert timesteps.ndi...
303
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, Aut...
318
0
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.testi...
368
from __future__ import annotations class __lowercase : """simple docstring""" def __init__( self , lowerCAmelCase__ = 0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Dict = key ...
162
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabl...
308
1
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def SCREAMING_SNAKE_CASE__ ( __a , __a , __a ): if not arr: return None, None, 0 if low == high: return low, high, arr[lo...
356
def SCREAMING_SNAKE_CASE__ ( __a , __a = False ): if not isinstance(__a , __a ): snake_case_ : str = f"""Expected string as input, found {type(__a )}""" raise ValueError(__a ) if not isinstance(__a , __a ): snake_case_ : int = f...
88
0
"""simple docstring""" import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _UpperCAmelCase : @property def a ...
332
'''simple docstring''' def _A ( A__ = 10 , A__ = 22 ): """simple docstring""" __lowercase = range(1 , A__ ) __lowercase = range(1 , A__ ) return sum( 1 for power in powers for base in bases if len(str(base**power ) ) == pow...
104
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=a__ ): UpperCAmelCase__ : Optional[int] = ["note_seq"] def __init__( self, *SCREAMING_SNAKE_CASE_, **SCREAMING_SNAKE_CASE_ ) -> Tuple: requires_backends(self...
361
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState f...
103
0
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __lowerCamelCase ( __snake_case : Tuple ) -> Dict: """simple docstring""" A__ : str ...
134
'''simple docstring''' __snake_case : Tuple = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' __snake_case : List[str] = [{'type': 'code', 'content'...
134
1
"""simple docstring""" import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig f...
168
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_commo...
168
1
"""simple docstring""" import argparse import os import re _lowercase : Optional[Any] = "src/transformers" # Pattern that looks at the indentation in a line. _lowercase : List[str] = re.compile(r"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. _lowercas...
238
"""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 _lowercase : Optional[int] = "▁" _lowercase : Optional[Any] ...
238
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to ta...
355
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
216
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''...
87
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not i...
243
0
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 @slow class __UpperCAme...
355
from __future__ import annotations import queue class __UpperCAmelCase : def __init__( self : str, __A : Union[str, Any] ): UpperCAmelCase : Dict = data UpperCAmelCase : Tuple = None UpperCAmelCase : Any = None ...
99
0
'''simple docstring''' import os import time import numpy as np import onnxruntime as ort lowerCamelCase : Tuple = "1" lowerCamelCase : Optional[Any] = "0" lowerCamelCase : Dict = "1" lowerCamelCase : List[str] = ort.SessionOptions() lowerCamelCase : st...
47
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 RealmTokenizer ...
230
0
'''simple docstring''' A__ : Any = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] A__ : str = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] A__ : Tuple = { 0: '''Sunday''', 1: '''Monday''', 2: '''Tuesday''', 3: '''Wednesday''', 4: '''Thursday''', 5: '''Friday''', ...
0
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, to...
0
1
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_dir...
121
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase__ : Any = { 'huggingface/informer-tourism-monthly': ( 'https://huggi...
121
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVe...
366
import math def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> float: '''simple docstring''' if initial_intensity < 0: raise ValueError('The value of intensity cannot be negative' ) # handling of negative values of initial intensity if angle ...
169
0
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _A ( SCREAMING_SNAKE_CASE__ : Optional[int] , SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase :Optional[int] =...
259
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 UpperCAmelCase_ ( ) -> str: ...
225
0
"""simple docstring""" def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ): """simple docstring""" return round(float(moles / volume ) * nfactor ) def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ): """simple docstring""" retu...
351
"""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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( Bi...
30
0
"""simple docstring""" from __future__ import annotations def lowercase ( __snake_case : list[float] ): lowercase_ : str = 0.00 lowercase_ : str = 0 for resistor in resistors: if resistor <= 0: lowercase_ : str = ...
33
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { "huggingface/time-series-transformer-tourism-monthly": ( ...
221
0
'''simple docstring''' from __future__ import annotations import time import numpy as np lowerCAmelCase_ = [8, 5, 9, 7] lowerCAmelCase_ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] lowerCAmelCase_ = [ [3, 2, 1, 4], [0, 2, 5, 2],...
332
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import Lear...
332
1
"""simple docstring""" import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _UpperCAmelCase ( _snake_case , _snake_case ): @register_to_config def __init__( self : str , *...
332
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''RUCAIBox/mvp''': '''https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json''', } ...
162
0
import argparse import datetime def __lowercase ( _UpperCamelCase ) ->str: """simple docstring""" lowercase : str = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', '''3''': '''Wednesday''', ...
173
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = {'''vocab_file''': '''spiece...
173
1
'''simple docstring''' __snake_case ={ "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalori...
4
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @...
88
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """funnel-transformer/small""": """https://huggingface.co/funnel-transformer/small/resolve/main/config.json""", """funnel-t...
368
_UpperCAmelCase = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" def UpperCamelCase ( ): '''simple docstring''' A_ : Tuple = input('Enter message: ' ) A_ : int = input('Enter key [alphanumeric]: ' ) A_ : Optional[Any] = input('Encr...
192
0
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easi...
1
from datetime import datetime as dt import os from github import Github A__ : List[str] = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def UpperCamelCase( ): lowerCAmelCase_ : ...
103
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
def lowerCAmelCase__ ( a__ , a__ ) ->str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" _UpperCamelCase = str(bin(a__ ) ...
63
1
'''simple docstring''' import requests def _A (lowerCAmelCase__ :str , lowerCAmelCase__ :str ) -> None: '''simple docstring''' _a = {'Content-Type': 'application/json'} _a = requests.post(lowerCAmelCase__ , j...
168
'''simple docstring''' def _A (lowerCAmelCase__ :int , lowerCAmelCase__ :int , lowerCAmelCase__ :int ) -> float: '''simple docstring''' _a = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for ...
168
1
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def __lowercase ( *__lowerCAmelCase : Tuple , __lowerCAmelCase : Optional[Union[Dict, Any]] = None , __lowerCAmelCase : Any=True , __lowerCAmelCase :...
361
def __lowercase ( __lowerCAmelCase : int ): if num <= 0: raise ValueError('Input must be a positive integer' ) a__ = [True] * (num + 1) a__ = 2 while p * p <= num: if primes[p]: for i i...
109
0
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_...
44
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter lowercase__ =True except ImportE...
216
0
"""simple docstring""" from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer from .base import PipelineTool SCREAMING_SNAKE_CASE : Optional[Any] = { '''Acehnese Arabic''': '''ace_Arab''', '''Acehnese Latin''': '''ace_Latn''', '''Mesopotamian Arabic''': '''acm_Arab''', ...
350
"""simple docstring""" def __UpperCAmelCase ( snake_case_ : int , snake_case_ : list[int] , snake_case_ : int ) -> int: """simple docstring""" def count_of_possible_combinations(snake_case_ : int ) -> int: if target < 0: r...
317
0
import os from collections.abc import Iterator def snake_case_ ( snake_case = "." ) -> Iterator[str]: for dir_path, dir_names, filenames in os.walk(A__ ): lowercase__: Dict = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] f...
196
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_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_co...
99
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
274
'''simple docstring''' snake_case__ : Optional[Any] = tuple[float, float, float] snake_case__ : Tuple = tuple[float, float, float] def _lowerCamelCase ( lowerCamelCase_ : Pointad , lowerCamelCase_ : Pointad ): """simple docstring""" ...
274
1
UpperCAmelCase__ = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] UpperCAmelCase__ = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] UpperCAmelCase__ = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: "Thursday", 5: "Friday", 6: "Saturday", } def _a...
0
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_d...
0
1
'''simple docstring''' import argparse import hashlib # hashlib is only used inside the Test class import struct class _snake_case : def __init__( self , a__ ) -> str: '''simple docstring''' snake_case_ = data snake_case_ = [0...
364
'''simple docstring''' def UpperCamelCase_( snake_case : list[int] , snake_case : int ): '''simple docstring''' snake_case_ = len(snake_case ) snake_case_ = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] ...
92
0
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
100
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger _lowerCAmelCase : int = get_logger(__name__) _lowerCAmelCase : Any = r"\n Args:\n input_ids (`jnp.ndarray` of shape...
169
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=A_ ): lowercase__ = ['''speech'''] def __init__( self : Union[str, Any] , *snake_case_ : Optional[int] , **snake_case_ : str ) ...
230
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''tokenizer'''] lowercase__ = '''AutoImageProcessor''' lowercase__ ...
230
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusio...
89
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, requir...
30
0
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings SCREAMING_SNAKE_CASE_:Any = logging.getLog...
362
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE_:Optional[Any] = logging.get_lo...
115
0
"""simple docstring""" from __future__ import annotations import time import numpy as np _lowercase : List[Any] = [8, 5, 9, 7] _lowercase : List[str] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] _lowercase : ...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
import os import re import shutil import sys import tempfile import unittest import black UpperCAmelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import check_copies # noqa: E402 # This is the reference code...
267
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_xglm""": ["""XGLM_PRETRAINED_CON...
267
1
"""simple docstring""" import os import pytest from attr import dataclass _UpperCAmelCase = """us-east-1""" # defaults region @dataclass class a : UpperCamelCase : str UpperCamelCase : str = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' UpperCamelCase : List[st...
173
"""simple docstring""" 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.p...
173
1
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def UpperCAmelCase ( UpperCAmelCase ) -> List[Any]: snake_case_ = [ 'encoder.version', 'decoder.version', 'model.encoder.version', 'model.d...
363
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def UpperCAmelCase ( UpperCAmelCase ) -> Dict: # vision encoder if "img_encoder.pos_embed" in name: snake_case_ = name...
312
0
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel SCREA...
321
import string def UpperCamelCase (lowercase_: str ) -> None: for key in range(len(string.ascii_uppercase ) ): A__ : Dict = """""" for symbol in message: if symbol in string.ascii_uppercase: A__ : Dict = string.ascii_uppercase.find(lowercase...
192
0
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def A (__A : Union[str, Any] , __A : Any , __A : Tuple ) ...
360
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __sn...
7
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tenso...
63
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transf...
63
1
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __A : Union[str, Any] = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': o...
323
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smartaa_timesteps, sma...
323
1
import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sentencepiece @requi...
10
"""simple docstring""" import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging A: str = logging.get_logger(__name__) A: List[Any] = {"vocab_file": "vocab.txt"} A: ...
109
0
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py snake_case : Tuple = '''src/diffusers''' # Matches is_xxx_available() snake_case : List[str] = re.comp...
109
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 ...
109
1
def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' snake_case_ = """""" for i in table: res += inp[i - 1] return res def __lowerCamelCase ( UpperCamelCase__ ): '''simple doc...
285
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : Any , ...
317
0
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from d...
363
"""simple docstring""" from functools import lru_cache @lru_cache def a_ ( _lowercase ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__...
128
0
import argparse import os import re import packaging.version A : Dict = '''examples/''' A : Optional[Any] = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.compile(R'''^...
274
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean A : str = 0 A : Any = [ [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...
274
1
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake lowercase__ : Tuple = numpy.array([0, 0]) lowercase__ : Optional[Any] = numpy.array([0.5, 0.866_0254]) lowercase__ : An...
287
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def a__ ( lowercase : Tuple ) -> Dict: """simple docstring""" _U...
287
1
'''simple docstring''' from __future__ import annotations import time import numpy as np a : Dict = [8, 5, 9, 7] a : int = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a : int = [ [3, 2, 1, 4], [0, 2, 5, 2], [5,...
56
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, SingleSentenceClassifi...
92
0
import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available, ) from . import BaseT...
117
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS...
117
1
import random from .binary_exp_mod import bin_exp_mod def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase=1000 ) -> str: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd ...
230
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner im...
230
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) _lowerCamelCase : Tuple = { """...
362
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file, and...
231
0
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def _UpperCamelCase ( lowercase__ ): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.c...
9
"""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 .test_pipelin...
115
0
"""simple docstring""" from collections import defaultdict class A__ : '''simple docstring''' def __init__( self: Optional[int] , _SCREAMING_SNAKE_CASE: Tuple , _SCREAMING_SNAKE_CASE: Tuple) -> Any: """simple docstring""" ...
356
"""simple docstring""" import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCr...
58
0
'''simple docstring''' def a__ ( a__ = 10_00 ): """simple docstring""" __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = 1, 1 __SCREAMING_SNAKE_CASE = [] for i in range(1 , n + 1 ): __SCREAMING_SNAKE_CASE = prev_numerato...
267
'''simple docstring''' # 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 # # ...
267
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case : Optional[Any] = { 'configuration_efficientformer...
361
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelFo...
179
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging snake_case__ : Optional[Any] = logging.get_logger(__name__) def _snake_case ( _snake_case : Union[tf.Tensor, np.ndarray] ): if isinstance(_snake_case ...
60
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness UpperCAmelCase_ = '\\n@misc{chen2021evaluating,\n title={Eva...
346
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ ...
353
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_al...
4
0
from __future__ import annotations import os from collections.abc import Mapping lowerCAmelCase__ = tuple[int, int] class lowerCAmelCase__ : '''simple docstring''' def __init__( self , __lowerCamelCase , __lowerCamelCase) -> None: _A : ...
11
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "t5-small": "https://huggingface.co/t5-small/resolve/main/config.json...
7
0
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common impor...
151
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
151
1
'''simple docstring''' import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __UpperCAmelCase = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge,...
323
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __A ( lowerCamelCase_ ): "...
323
1
"""simple docstring""" import pprint import requests UpperCAmelCase: Tuple = """https://zenquotes.io/api""" def __SCREAMING_SNAKE_CASE ( ): return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __SCREAMING_SNAKE_CASE ( ): return requests.ge...
336
"""simple docstring""" import pprint import requests UpperCAmelCase: Tuple = """https://zenquotes.io/api""" def __SCREAMING_SNAKE_CASE ( ): return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __SCREAMING_SNAKE_CASE ( ): return requests.ge...
336
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp ...
109
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A: str = { "configuration_distilbert": [ "DISTILBERT_PRETRAI...
109
1
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogr...
367
UpperCAmelCase : Dict = [0, 2, 4, 6, 8] UpperCAmelCase : Tuple = [1, 3, 5, 7, 9] def _A ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ): "...
148
0
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMix...
98
def _lowerCAmelCase (_lowerCAmelCase): if n_term == "": return [] UpperCamelCase_ = [] for temp in range(int(_lowerCAmelCase)): series.append(f"""1/{temp + 1}""" if series else "1") return series if __name__ == "__main__": UpperCAmelCase : ...
128
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE__ ) class UpperCAmelCase ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
301
def lowerCamelCase__ ( a = 10**9 ) -> int: _A: Dict = 1 _A: Union[str, Any] = 2 _A: List[str] = 0 _A: List[Any] = 0 _A: int = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter prev_value += 2 * value value +...
301
1
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__ ( __SCREAMING_SNA...
287
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 TFCamembertMode...
287
1
'''simple docstring''' import math from collections.abc import Callable def UpperCamelCase ( _lowerCamelCase : Callable[[float], float] , _lowerCamelCase : float , _lowerCamelCase : float ): A__ = xa A__ = xa while True: if x_n == x_na or function...
363
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : int = 1_00_00_00 ): A__ = set(range(3 , _lowerCamelCase , 2 ) ) primes.add(2 ) for p in range(3 , _lowerCamelCase , 2 ): if p not in primes: continue primes.difference_...
123
0
from math import sqrt def _a ( lowerCamelCase: int ) -> int: '''simple docstring''' __A = 0 for i in range(1 , int(sqrt(lowerCamelCase ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCamelCase ): t...
117
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 snake_case__ : ...
117
1
'''simple docstring''' from math import factorial, radians def __lowercase ( __lowercase , __lowercase = 18 , __lowercase = 10 ) -> float: '''simple docstring''' _A = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from ...
174
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowerCamelCase_ = { '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHI...
174
1
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTe...
195
import os import re import shutil import sys import tempfile import unittest import black _A = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is the reference code that will be used ...
231
0
from __future__ import annotations from math import gcd def SCREAMING_SNAKE_CASE ( snake_case_ : int , snake_case_ : int = 2 , snake_case_ : int = 1 , snake_case_ : int = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm. if n...
286
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( snake_case_ : Tuple , snake_case_ : str , snake...
286
1
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 transformers import ( Effici...
94
'''simple docstring''' 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 ) lowercase_ = logging.getLogger(__name__) if __name__ == "__m...
58
0
'''simple docstring''' from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE : Dict , _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CASE : str ) -> Dict: # noqa: E741 """simple docstring""" ...
359
'''simple docstring''' import os from pathlib import Path def a__ ( ) -> Union[str, Any]: """simple docstring""" from torch.utils.cpp_extension import load UpperCAmelCase_ : Union[str, Any] = Path(_SCREAMING_SNAKE_CASE ).resolve().parent.parent....
67
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase : Optional[int] ={ '''configuration_efficientf...
223
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp ...
179
0
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __lowerCamelCase ( __a :Dict , __a :List[Any]=7 ) -> Union[str, Any]: """simple docs...
352
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": A : List[str] = argparse.ArgumentParser( description=( '''Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned''' ...
276
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ......
70
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __snake_case ="""\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding ...
4
0
from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils import load_image if is_torch_avai...
351
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', 'XCLIPVisionConfig', ], ...
119
0
'''simple docstring''' import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import log...
151
'''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 lowercase__ = logging.get_logger(__name__) lowercase__ =...
151
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, to...
368
from math import sqrt def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = 0 for i in range(1 , int(sqrt(lowercase ) + 1 ) ): if n % i == 0 and i != sqrt(lowercase ): total += i + n // i elif i ==...
319
0