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
def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase ) -> int: """simple docstring""" snake_case_ : Optional[int] = [1] for i in range(2 , _UpperCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < ...
60
from typing import Any class __lowercase : def __init__( self , lowercase_) -> str: __snake_case = data __snake_case = None def __repr__( self) -> str: return F"Node({self....
313
0
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm _lowerCAmelCase = 2048 _lowerCAmelCase = 4096 _lowerCAmelCase = 42 _lowerCAmelCase = os.environ.pop("PROCESS_TRAIN", "false") _lowerCAmelCase = {"null": 0, "short": 1, "long":...
245
'''simple docstring''' from collections.abc import Callable def UpperCamelCase ( a , a , a ) -> float: '''simple docstring''' __magic_name__ = a __magic_name__ = b if function(a ) == 0: # one of the a or b is a root for the function ...
245
1
lowerCamelCase : Optional[Any] = 8.314_4598 def _SCREAMING_SNAKE_CASE ( lowercase : float , lowercase : float ): '''simple docstring''' if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) ...
70
"""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 lowerCamelCase__ : int = logging.get_logger(__name...
238
0
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class UpperCamelCase ( ctypes.Structure ): """simple docstring""" # _fields is a specific attr expected by ctypes SCR...
600
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: _lowercase : Union[str, Any] = ...
600
1
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, Ima...
41
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension...
228
0
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin,...
721
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTest...
109
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_cha...
495
"""simple docstring""" import logging import os from .state import PartialState class lowercase ( logging.LoggerAdapter ): @staticmethod def _snake_case ( lowercase ) -> Optional[Any]: lowerCAmelCase = PartialState() return n...
532
0
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap lowercase_ = """Usage of script: script_name <size_of_canvas:int>""" lowercase_ = [0] * 100 + [1] * 10 random.shuffle(choice) def __UpperC...
715
from string import ascii_uppercase lowercase_ = {str(ord(c) - 55): c for c in ascii_uppercase} def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> str: if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise TypeError('int()...
45
0
from ... import PretrainedConfig lowerCamelCase : Dict = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class __lowercase (lowerCamelCase__ ): """simple docstring""" _snake_case = NEZHA_PRETRAINED_...
587
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository ...
327
0
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __UpperCAmelCase : Optional[Any] = (3, 9, -11, 0, 7, 5, 1, -1) __UpperCAmelCase : int = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class lowerCamelCase : UpperCAmelCase : ...
249
from manim import * class lowerCamelCase ( SCREAMING_SNAKE_CASE ): def snake_case_ ( self : int ) -> Tuple: _a : Optional[int] = Rectangle(height=0.5 , width=0.5 ) _a : Dict = Rectangle(height=0.25 , width=0...
249
1
import qiskit def UpperCamelCase( __UpperCamelCase : int ,__UpperCamelCase : int ): lowerCAmelCase_ : List[str] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register lowerCAmelCase_ : Union[str, Any] ...
171
def UpperCamelCase( __UpperCamelCase : int = 10**12 ): lowerCAmelCase_ : Tuple = 1 lowerCAmelCase_ : str = 0 lowerCAmelCase_ : Tuple = 1 lowerCAmelCase_ : Dict = 1 while numerator <= 2 * min_total - 1: prev_numer...
171
1
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def SCREAMING_SNAKE_CASE ( lowercase_ : Union[str, Any] ): lowercase = os.path.join(args.tf_model_dir , """pa...
653
'''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[Any] = logging.get_logger(__name__) lowercase...
653
1
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_mbart''': ['''MBART_PRETRAINED_...
84
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils ...
358
0
'''simple docstring''' import random def A_ ( _lowerCAmelCase : int , _lowerCAmelCase : float , _lowerCAmelCase : bool = False ): """simple docstring""" _lowerCamelCase : dict = {i: [] for i in range(_lowerCAmelCase )} # if p...
700
'''simple docstring''' from math import sqrt def A_ ( _lowerCAmelCase : int = 1000000 ): """simple docstring""" _lowerCamelCase : int = 0 _lowerCamelCase : int = 0 _lowerCamelCase : int while num_cuboids <= limit: ...
11
0
import math def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' return math.pow(snake_case__ , 2 ) - a def a ( snake_case__: float ): '''simple docstring''' return 2 * x def a ( snake_case__...
97
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .test_pipelines_...
562
0
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np lowerCAmelCase_ : str = re.compile(R'\b(a|an|the)\b', re.UNICODE) lowerCAmelCase_ : List[str] = None def _lowerCamelCase ...
700
'''simple docstring''' lowerCAmelCase_ : Optional[Any] = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _lowerCamelCase ( lowercase : Union[str, Any] , ...
521
0
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionS...
189
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __snake_case = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: ...
189
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanorama...
277
import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOut...
277
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : int = logging.get_logger(__name__) lowerCAmelCase__ : List[Any] = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-ba...
347
'''simple docstring''' from math import factorial def _a ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : float ): """simple docstring""" if successes > trials: raise ValueError('''successes must be lower or equal to trials''' ) if trials < 0 or...
347
1
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def _A ( A ,A ...
714
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunD...
425
0
"""simple docstring""" import string import numpy def lowercase (SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> int: return b if a == 0 else greatest_common_divisor(b % a , SCREAMING_SNAKE_CASE_ ) class lowerCAmel...
247
"""simple docstring""" from collections.abc import Callable def lowercase (SCREAMING_SNAKE_CASE_ : Callable[[float], float] , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ) -> float: SCREAMING_SNAKE_CASE = ...
247
1
from __future__ import annotations from functools import lru_cache from math import ceil _a : int = 1_00 _a : List[str] = set(range(3, NUM_PRIMES, 2)) primes.add(2) _a : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: continue p...
571
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 Ba...
571
1
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_ ( snake_case_ ): _A : Optional[int] = [] if...
307
import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import ConfigTester from ......
307
1
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: A_ = None try: import msvcrt except ImportError: A_ = None try: import fcntl except ImportError: A_ ...
719
'''simple docstring''' def A_ ( snake_case ): SCREAMING_SNAKE_CASE:Dict = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def A_ ( snake_case = 5000 ): SCREAMING_SNAKE_CASE:int = [(i * (3 * i - 1)) // 2 for i in range(1 , snake_case )] ...
465
0
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants lowercase__ : List[Any] = 3_00 # TEMPERATURE (unit = K) def __lowercase ( _a , _a , _a , ): if donor_conc <= 0: raise ValueError('''Don...
123
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_...
123
1
import operator as op SCREAMING_SNAKE_CASE__ = '''scaler.pt''' SCREAMING_SNAKE_CASE__ = '''pytorch_model''' SCREAMING_SNAKE_CASE__ = '''random_states''' SCREAMING_SNAKE_CASE__ = '''optimizer''' SCREAMING_SNAKE_CASE__ = '''scheduler''' SCREAMING_SNAKE...
705
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torc...
577
0
"""simple docstring""" import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pi...
560
'''simple docstring''' import doctest from collections import deque import numpy as np class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Tuple ): """simple docstring""" UpperCamelCase ...
430
0
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def lowerCAmelCase ( UpperCamelCase__ : Tuple="ro" , UpperCamelCase__ : Any="en" , UpperCamelCase__ : Dict="wmt16" , UpperCamelCase__ : Dict=None ): ...
712
'''simple docstring''' from ..utils import DummyObject, requires_backends class A ( metaclass=UpperCAmelCase ): a_ = ['''torch'''] def __init__( self : Optional[int] , *__a : List[str] , **__a : Union[str, Any]...
654
0
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore A__ : Dict = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" A__ : Any = [file for file in filepaths i...
233
from math import isclose, sqrt def _a ( __UpperCamelCase : float ,__UpperCamelCase : float ,__UpperCamelCase : float ): lowerCAmelCase__ : Union[str, Any] = point_y / 4 / point_x lowerCAmelCase__ : str = 2 * normal_gradient / (1 + normal_g...
233
1
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _A (__a , __a , __a ) -> Optional[Any]: """simp...
720
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, tr...
176
0
"""simple docstring""" import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowerCamelCase ( unittest.TestCase ): '''simple docstring''' def _a (self ): """simple docstrin...
182
"""simple docstring""" def a__ ( ) -> Union[str, Any]: UpperCAmelCase__ : Dict = [] UpperCAmelCase__ : Tuple = 1 while len(lowerCAmelCase ) < 1E6: constant.append(str(lowerCAmelCase ) ) i += 1 UpperCAmelCase__ ...
182
1
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = [1] UpperCAmelCase , UpperCAmelCase , UpperCAmelCase = 0, 0, 0 UpperCAmelCase = ugly_nums[ia] * 2 UpperCAm...
378
"""simple docstring""" from __future__ import annotations import pandas as pd def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = [0] * no_of_processes UpperCAmelCase = ...
378
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json', # See all ViT...
485
from math import asin, atan, cos, radians, sin, sqrt, tan SCREAMING_SNAKE_CASE = 6_37_81_37.0 SCREAMING_SNAKE_CASE = 6_35_67_52.31_42_45 SCREAMING_SNAKE_CASE = 6378137 def _lowerCamelCase ( __A : float , __A : float , __A : float , __...
485
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec ...
712
from __future__ import annotations def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> list[int]: lowercase__ : List[str] = [True] * limit lowercase__ : Union[str, Any] = False lowercase__ : List[str] = False ...
298
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : str ): """simple docstring""" assert column_title.isupper() __a = 0 __a = len(_SCREAMING_SNAKE_CASE ) - 1 __a = 0 while index >= 0: __a = (ord(column_title[index] ) - 64) * pow(26 , ...
225
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : list ): """simple docstring""" __a = len(_SCREAMING_SNAKE_CASE ) for _ in range(_SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: ...
225
1
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _lowercase ) -> Optional[int]: _lowercase : Union[str, Any] = str(_snake_case ) return n == n[::-1] def __UpperCamelCase ( _lowercase = 100_0000 ) -> An...
710
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __UpperCamelCase ( _lowercase ) -> None: _lowercase , _lowercase : List[Any] = analyze_text(_lowercase ) _lowercase ...
4
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __snake_case = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig'''...
189
'''simple docstring''' import requests from bsa import BeautifulSoup def a ( __a = "AAPL" ) -> str: '''simple docstring''' UpperCamelCase__ :str = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' UpperCamelCase__ :Tuple = BeautifulSoup(re...
189
1
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 from flax.serialization import from_b...
700
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def _snake_case( SCREAMING_SNAKE_CASE__ : str ) -> Tuple: '''simple docstring''' A__ = [ 'encoder.version', ...
586
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _UpperCAmelCase ( lowercase , unittest.TestCase ): lo...
631
import argparse import os import re import packaging.version SCREAMING_SNAKE_CASE__ = "examples/" SCREAMING_SNAKE_CASE__ = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__version__\s+=\s+\...
631
1
"""simple docstring""" from __future__ import annotations a : List[Any] = list[tuple[int, int]] a : str = [ [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], [...
716
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def _SCREAMING_SNAKE_CASE ( _lowercase : Optional[int] , _lowercase : Optional[Any] , _lowercase : Union[str, Any] ) ->Dict: '''...
31
0
'''simple docstring''' UpperCamelCase_ = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def lowercase__( __UpperCamelCase: dict ,__UpperCamelCase: Dict ...
28
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_ver...
654
0
from __future__ import annotations def UpperCamelCase ( _a , _a , _a ) -> tuple[float, list[float]]: '''simple docstring''' lowercase_ :Optional[int] = list(range(len(_a ) ) ) lowercase_ :int = [v / w for ...
441
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_...
441
1
from collections import defaultdict class _lowerCAmelCase: """simple docstring""" def __init__( self , _lowerCamelCase , _lowerCamelCase ): UpperCamelCase_: List[str] = total # total no of tasks (N) ...
57
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE )-> Dict: _SCREAMING_SNAKE_CASE : Any = ...
338
0
"""simple docstring""" def __snake_case ( ) -> int: """simple docstring""" for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def __snake_case ( UpperCamelCase__ ) -> str: """simple docstring""" A = 1 A = 2 while...
91
"""simple docstring""" def __snake_case ( UpperCamelCase__ , UpperCamelCase__ ) -> int: """simple docstring""" while b: A , A = b, a % b return a def __snake_case ( UpperCamelCase__ , UpperCamelCase__ ) -> int: """simple docst...
91
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor lowerCAmelCase: Union[str, Any] = logging.get_logger(__name__) class a__( lowerCamelCase__ ): def __init__( self : Optional[Any] , *__snake_cas...
526
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Tuple = logging.get_logger(__name__) lowerCAmelCase: Any = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json', # See al...
526
1
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 ...
714
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class lowercase__( UpperCAmelCase , unitt...
409
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Any = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_available(...
210
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def lowerCamelCase__ ( A : str = "isbn/0140328726" ): '''simple docstring''' UpperCAmelCase = olid.strip().strip('''/''' ) # Remove leading/tr...
210
1
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....
209
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'vocab...
209
1
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentPars...
522
"""simple docstring""" import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCamelCase_ ( *UpperCAmelCase_ ) ->Optional[int]: """simple docstring""" if not isinstance(UpperCAmelCase_ , ...
522
1
import math import os import sys def UpperCAmelCase__( __UpperCAmelCase : str ): __snake_case : Union[str, Any] = '' try: with open(__UpperCAmelCase , 'rb' ) as binary_file: __snake_case : Optional[Any] = binary_file.read() for dat i...
679
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __magic_name__ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( UpperCamelCase): """simple docstring""" def __init__( self , *_UpperCAmelCase , **_Upp...
679
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor _lowerCAmelCase :Union[str, Any] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): '''simple docstring''' def __init__( self , ...
506
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : str ): return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
506
1
def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
671
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _UpperCAmelCase : """simple docstring""" lowercase__ = 42 lowercase__ = 42 class _UpperCAmelCase ...
671
1
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[int] ): # This function is recursive __UpperCAmelCase = len(snake_case_ ) # If the array contains only one element, we return it (it's the stop condition of # recu...
49
UpperCamelCase = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] UpperCamelCase ...
520
0
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase ( lowercase_ , unittest.TestC...
687
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __snake_case : List[str] = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeB...
687
1
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_utils i...
37
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_logging sys.path.append(os.pa...
37
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaPr...
143
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_...
143
1
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "google/umt5-small": "https://huggingface.co/go...
11
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A ( UpperCamelCase_ : List[Any] ) -> Tuple: '''simple docstring''' if "img_encoder.pos_embed" in name: ...
48
0
def SCREAMING_SNAKE_CASE ( lowercase_ : list ): def merge(lowercase_ : list , lowercase_ : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) ...
705
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers impor...
653
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 a__ : List[str] = """scheduler_config.json""" class lowercase ( ...
165
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ : Any = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Wav2Vec2Conf...
165
1
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils import ...
716
from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Any = logging.get_logger(__name__) __A : int = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ( A ): ...
450
0
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np A_ = re.compile(R"\b(a|an|the)\b", re.UNICODE) A_ = None def UpperCamelCase__ ( ) -> Optional[Any]: snake_case__ : List[...
270
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: if not is_torch_available(): ...
132
0
def __lowerCamelCase ( __lowerCAmelCase : int = 100 ) -> int: __UpperCamelCase : Optional[Any] = n * (n + 1) * (2 * n + 1) / 6 __UpperCamelCase : Any = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == ...
515
def __lowerCamelCase ( __lowerCAmelCase : list ) -> list: __UpperCamelCase : Dict = len(__lowerCAmelCase ) for i in range(1 , __lowerCAmelCase ): __UpperCamelCase : Dict = collection[i] __UpperCamelCase : Option...
515
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects i...
31
'''simple docstring''' import re def __lowerCamelCase ( __lowerCAmelCase : str ) -> list: return [char.split() for char in re.split(r"""[^ a-z A-Z 0-9 \s]""" , str_ )] def __lowerCamelCase ( __lowerCAmelCase : str ) -> ...
369
0
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa...
447
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 = logging.get_logger(__name__) _lowerCamelCase = """https://o...
447
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[str] = logging.get_logger(__name__) __A : Dict = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } ...
394
import qiskit def lowerCamelCase_ ( UpperCamelCase_ , UpperCamelCase_ ): _a : Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) _a : Any = qiskit.QuantumCircuit(4 , 2 ) # encode inputs in qubits 0 and 1 if bita == 1: ...
471
0
'''simple docstring''' import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPV...
572
'''simple docstring''' import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase f...
572
1
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_co...
387
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docst...
387
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _snake_case : Dict = logging.get_logger(__name__) class a (UpperCAmelCase_ , UpperCAmelCase_ ): ...
707
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import torch.nn as nn fro...
203
0
"""simple docstring""" def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> float: def get_matched_characters(lowerCAmelCase_ , lowerCAmelCase_ ) -> str: _snake_case = [] _snake_case = min(len(_stra ) , len(_stra ) ) // 2 for i, ...
103
"""simple docstring""" 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 UpperCAmelCase ( A : ...
573
0
'''simple docstring''' def lowerCAmelCase_ ( a : int , a : int ): if number < 0 or shift_amount < 0: raise ValueError('both inputs must be positive integers' ) a__ = str(bin(a ) ) binary_number += "0" * shift_amount ...
126
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
126
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { "YituTech/conv-bert-base": "https://huggingface...
77
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...
419
0
from collections.abc import Callable import numpy as np def lowerCAmelCase_ ( lowercase: Callable , lowercase: float , lowercase: float , lowercase: float , lowercase: float ) -> np.array: '''simple docstring''' _UpperCamelCase: Tuple...
264
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
264
1
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class _lowerCAmelCase ( ...
282
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.d...
282
1
'''simple docstring''' from string import ascii_uppercase SCREAMING_SNAKE_CASE__ : Union[str, Any] = {char: i for i, char in enumerate(ascii_uppercase)} SCREAMING_SNAKE_CASE__ : List[str] = dict(enumerate(ascii_uppercase)) def a ( UpperCamelCase_ : str , UpperCam...
581
'''simple docstring''' import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_...
581
1
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets snake_case__ = datasets.logging.get_logger(__name__) snake_case__ = """\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Text Generation}, author={Thibault ...
583
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 lowerCamelCase_ ( UpperCAme...
583
1
from __future__ import annotations from decimal import Decimal from numpy import array def lowerCAmelCase ( lowerCAmelCase_ ): lowerCAmelCase_ : Optional[int] = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x2 matrices...
702
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import...
619
0
import random def __UpperCAmelCase ( __a : int ) -> bool: """simple docstring""" _a : str = num - 1 _a : Dict = 0 while s % 2 == 0: _a : Dict = s // 2 t += 1 for _ in rang...
14
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __UpperCAmelCase ( __a : ...
14
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A = "▁" _A = {"vocab_file": "spiece.model"} _A = { "vocab_file": {"google/pegasus-xsum": "ht...
279
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipelin...
279
1
'''simple docstring''' import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): SCREAMING_SNAKE_CASE_ = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: true\nsubse...
523
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torc...
523
1
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller UpperCAmelCase__ =3 def lowerCAmelCase_ ( UpperCamelCase__ : Union[str, Any] ): """simple docstring""" print("""Generati...
706
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES UpperCAmelCase__ =logging.get_logger(__name__) UpperCAmelCase__ ...
442
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_im...
23
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.tes...
412
0
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _...
170
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json''', } class _lowerCAmel...
170
1
'''simple docstring''' import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase f...
11
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowercase__ :Union[str, Any] = HfApi() lowercase__ :Optional[Any] = {} # fmt: off lowercase__ :Optional[int] = torch....
522
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __a ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> int:...
308
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils...
308
1
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline _lowerCamelCase = argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) parse...
71
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase = get_tests_dir('fixtures/spiece.model') ...
464
0
import unittest from knapsack import knapsack as k class lowerCAmelCase_ ( unittest.TestCase ): def UpperCamelCase_ ( self : Tuple ): _UpperCamelCase = 0 _UpperCamelCase = [0] _UpperCamelCase = [0] ...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { "EleutherAI/gpt-neox-20b": "https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json", # See all GPTNeoX models at https://huggingface.c...
71
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ : Union[str, Any] = { """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ChineseC...
12
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[Any] = logging.get_logger(__name__) a : List[Any] = { '''microsoft/unispeech-sat-base-100h-libri-ft''': (...
633
0
"""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 UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = ...
700
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
475
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : List[str] = logging.get_logger(__name__) __A : List[str] = { '''andreasmadsen/efficient_mlm_m0.40''': ( ...
343
__A : Optional[Any] = '''Input must be a string of 8 numbers plus letter''' __A : str = '''TRWAGMYFPDXBNJZSQVHLCKE''' def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> bool: '''simple docstring''' if not isinstance(_UpperCAmelCase, _UpperCAmelCase ): ...
343
1
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 from flax.serialization import from_bytes, to_bytes fro...
86
def __magic_name__ ( __a : str , __a : str ): '''simple docstring''' UpperCamelCase__ = len(__a ) UpperCamelCase__ = len(__a ) UpperCamelCase__ = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] UpperCamelCase__ = True for i in...
86
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class a ( __SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase_ : List[str] = (DDIMParallelScheduler,) UpperCamelCase_ : Optional[An...
332
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_a...
332
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Tuple = { 'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/main/config....
713
"""simple docstring""" import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common impor...
2
0
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : Tuple = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'f...
640
0
A_ = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def __UpperCamelCase ( a) ->int: lowerCamelCase__ = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared += DIGITS...
360
def __UpperCamelCase ( a = 100) ->int: lowerCamelCase__ = (n * (n + 1) // 2) ** 2 lowerCamelCase__ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(f"""{solution() = }""")
360
1
"""simple docstring""" from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _lowerCAmelCase : str = numpy.array([0, 0]) _lowerCAmelCase : Dict = numpy.array([0.5, 0.8_6_6_0_2_5_4]) _lowerCAmelCase ...
289
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCAmelCase : Any = HfApi() _lowerCAmelCase : int = {} # fmt: off _lowerCAmelCase : List[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_...
289
1
'''simple docstring''' import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
703
'''simple docstring''' import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedCon...
305
0
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset f...
543
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelM...
543
1
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __UpperCamelCase (_UpperCAmelCase ): __A = ...
720
'''simple docstring''' import os def SCREAMING_SNAKE_CASE ( ): lowercase = os.path.join(os.path.dirname(lowercase_ ) , """num.txt""" ) with open(lowercase_ ) as file_hand: return str(sum(int(lowercase_ ) for line in file_hand ) ...
653
0
from datetime import datetime import matplotlib.pyplot as plt import torch def a ( A__ ) -> List[Any]: '''simple docstring''' for param in module.parameters(): SCREAMING_SNAKE_CASE__ : Optional[int] = False def a ( ) -> Dict: ...
35
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class lowercase ( unittest.TestCase ): lowerCamelCase : List[Any] = inspect...
35
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ :List[str] = logging.get_logger(__name__) UpperCAmelCase__ ...
483
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_...
483
1