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
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def snake_case_ ( _lowerCAmelCase : Any ) -> Tuple: if "model" in orig_key: UpperCAmelCase : Dict = orig_key.replace('''mod...
23
'''simple docstring''' from __future__ import annotations def snake_case_ ( _lowerCAmelCase : list[int | float] , _lowerCAmelCase : int , _lowerCAmelCase : int ) -> int | float: if len(_lowerCAmelCase ) == 0: raise ValueE...
23
1
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from...
355
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowerCAmelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": _...
248
0
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def a( A : Optional[Any] ) -> Optional[int]: # picklable for m...
227
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase: str = logging.get_logger(__name__) _lowercase: List[str] = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ), ...
227
1
'''simple docstring''' def _lowerCAmelCase ( lowerCamelCase_ : Optional[int] ): stooge(lowerCamelCase_ , 0 , len(lowerCamelCase_ ) - 1 ) return arr def _lowerCAmelCase ( lowerCamelCase_ : Tuple , lowerCamelCase_ : Tu...
364
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer _SCREAMING_SNAKE_CASE = {'''vocab_file''': '''vocab.txt'...
217
0
def lowercase( UpperCamelCase_ , UpperCamelCase_ = " " ) -> list: '''simple docstring''' UpperCamelCase = [] UpperCamelCase = 0 for index, char in enumerate(UpperCamelCase_ ): if char == separator: split_words.append(string[last_index:index] ) UpperC...
343
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common im...
343
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Optional[int] = logging.get_logger(__name__) lowercase__ : List[str] = { 'BAAI/AltCLIP': 'https://huggingface....
352
"""simple docstring""" import os def __lowercase ( _a ): snake_case_ : Tuple = len(grid[0] ) snake_case_ : Optional[int] = len(_a ) snake_case_ : Union[str, Any] = 0 snake_case_ : Union[str, Any] = 0 snake_case_ : L...
155
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging ...
64
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCAmelCase__ (snake_case__ : Optional[int] , snake_case__ : Any=7 ): """simple docstring""" _snake_case...
64
1
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipelin...
184
'''simple docstring''' import os def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : List[str] = len(grid[0] ) lowerCAmelCase__ : int = len(UpperCamelCase ) lowerCAmelCase__ : Optional[int] ...
184
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable...
333
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokeniz...
70
0
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor import transformers from transfor...
110
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 @dataclass class ...
110
1
'''simple docstring''' import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig _UpperCAmelCase : List[Any] = logging.get_logger(__name__) _UpperCAm...
174
'''simple docstring''' def __magic_name__( lowerCamelCase, lowerCamelCase): assert x is not None assert y is not None __lowerCAmelCase = len(lowerCamelCase) __lowerCAmelCase = len(lowerCamelCase) # declaring the array for storing the dp values ...
174
1
'''simple docstring''' import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) ...
311
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A ( __snake_cas...
311
1
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowerCamelCase__ = TypeVar("""T""") def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> int: return (position - 1) // 2 def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> int: ...
212
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=__magic_name__ ) class A__ ( __magic_name__ ): lowercase = field(default='audio-cl...
212
1
"""simple docstring""" import requests SCREAMING_SNAKE_CASE = "" # <-- Put your OpenWeatherMap appid here! SCREAMING_SNAKE_CASE = "https://api.openweathermap.org/data/2.5/" def _SCREAMING_SNAKE_CASE ( lowercase_ = "Chicago" , lowercase_ = APPID ) -> dict: return r...
230
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRober...
230
1
import datasets from .evaluate import evaluate UpperCAmelCase_ : Optional[Any] = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={a...
32
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : Union[str, Any] ): """simple docstring""" stooge(snake_case__ , 0 , len(snake_case__ ) - 1 ) return arr def UpperCAmelCase__ (snake_case__ : List[Any] , snake_case__ ...
64
0
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFI...
353
def __lowerCamelCase ( lowerCAmelCase__ ): lowerCAmelCase__ = len(lowerCAmelCase__ ) for i in range(lowerCAmelCase__ ): for j in range(i + 1 , lowerCAmelCase__ ): if numbers[j] < numbers[i]: lowerCAmelCa...
119
0
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...fea...
49
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Union[str, Any] = logging.get_logger(__name__) __snake_case :Any = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } class ...
49
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar a_ = TypeVar("""T""") a_ = TypeVar("""U""") class __snake_case ( Generic[T, U] ): """simple docstring""" def __init__( self , __lowerCa...
291
"""simple docstring""" from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_availab...
291
1
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, A...
76
"""simple docstring""" def __magic_name__ ( lowercase , lowercase ): SCREAMING_SNAKE_CASE_: Union[str, Any] =int(lowercase ) # Initialize Result SCREAMING_SNAKE_CASE_: str =[] # Traverse through all denomination for denomination in reversed(l...
173
0
import math from collections.abc import Iterator from itertools import takewhile def UpperCamelCase (lowercase_: int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ar...
141
from argparse import ArgumentParser from . import BaseTransformersCLICommand def UpperCamelCase (lowercase_: int ) -> str: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class _a (__magic_name__ ): '''simple docstring'''...
141
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __snake_case : Optional[int] ={ 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertConfig', ...
129
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreT...
129
1
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command,...
355
'''simple docstring''' import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase : str = "AAPL" ): lowerCAmelCase = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowerCAmelCase = BeautifulSoup(requests.get(lowerCamelCase ...
55
0
from __future__ import annotations from typing import TypedDict class A__ ( snake_case__ ): """simple docstring""" __magic_name__ = 42 __magic_name__ = 42 def UpperCAmelCase__ (UpperCamelCase_ ): """simple docstring""" ...
127
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ...
127
1
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingfac...
117
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import Inter...
117
1
"""simple docstring""" import requests _SCREAMING_SNAKE_CASE : Tuple = '' # <-- Put your OpenWeatherMap appid here! _SCREAMING_SNAKE_CASE : Tuple = 'https://api.openweathermap.org/data/2.5/' def lowerCamelCase__ ( _low...
183
"""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''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class snake_case__ ( __lowercase ): """simple docstring""" lowerCamelCase = (CMStochasticIterativeScheduler,) lo...
361
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class snake_case__ : """simple docstring""" def __init__( self : Dict , UpperCamelCase__ : int , UpperCamelCase__ : MutableSeque...
83
0
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __UpperCAmelCase ( A__ ): '''simple docstring''' __lowerCAmelCase = '''''' __lowerCAme...
258
'''simple docstring''' from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. _lowerCamelCase : int = 10 def __a ( UpperCAmelCase , UpperCAmelCase , UpperCAm...
258
1
"""simple docstring""" import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .tr...
259
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def _lowerCamelCase ( ): '''simple docstring''' __lowerCAmelCase = {} __lowerCAmelCase = 2 while True: __lowerCAmelCase = factor_map.pop(_UpperCamelCase ...
259
1
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_sco...
189
import functools def lowerCamelCase__ ( _A , _A ): '''simple docstring''' if not isinstance(_A , _A ) or not all(isinstance(_A , _A ) for day in days ): raise ValueError("The parameter days should be a list of integers" ) ...
187
0
def lowercase_ ( _lowerCamelCase : int = 10 , _lowerCamelCase : int = 1000 , _lowerCamelCase : bool = True): assert ( isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerCamelCase , _lowerCamelCase) and isinstance(_lowerC...
333
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__A ) class snake_case_ ( __A ): # `task` is not a ClassVar since we want it to be part of the `asdict` output f...
333
1
import math def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' return math.sqrt(__A ) * math.sqrt(__A ) == num def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' UpperC...
65
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 import ModelTesterMixin, ...
52
0
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__ : Optional[Any] =logging.get_logger(__name__) lowerCAmelCase__ ...
355
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 a__ ( A__, A__, ...
162
0
def __magic_name__ ( A : int, A : int ): '''simple docstring''' if number < 0 or shift_amount < 0: raise ValueError("both inputs must be positive integers" ) a = str(bin(A ) ) binary_number += "0" * shift_amount return binary_number def __magi...
107
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixi...
107
1
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a__ : Union[str, Any] = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3....
19
import math def UpperCAmelCase_( a__ ): """simple docstring""" SCREAMING_SNAKE_CASE : Any = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(a__ ) def UpperCAmelCase_( a__ = 1 / 12_345 ): """simple docs...
19
1
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, DPR...
334
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _lowerCamelCase =2_00 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generation and must be sm...
334
1
def lowerCamelCase_ ( _a : str ): '''simple docstring''' return credit_card_number.startswith(("""34""", """35""", """37""", """4""", """5""", """6""") ) def lowerCamelCase_ ( _a : str ): '''simple docstring''' UpperCAmelCase_ : List[Any...
360
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar UpperCamelCase_ = TypeVar('''T''') UpperCamelCase_ = TypeVar('''U''') class _snake_case ( Generic[T, U] ): '''simple docstring''' def __init__( ...
59
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
18
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTok...
135
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_enviro...
103
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): import j...
103
1
'''simple docstring''' _lowercase : Tuple = 8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def snake_case_ ( __SCREAMING_SNAKE_CASE : float , __SCREAMING_SNAKE_CASE : float , __SCREAMING_SNAKE_CASE : float ): """simple docstring""" ...
93
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : int ): """simple docstring""" lowercase_ : Optional[int] = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion ...
93
1
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _SCREAMING_SNAKE_CASE ( ) -> ...
363
import random def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int , _lowerCamelCase : float , _lowerCamelCase : bool = False) -> dict: '''simple docstring''' __UpperCamelCase : dict = {i: [] for i in range(_low...
151
0
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : str ) -> bool: '''simple docstring''' UpperCAmelCase_ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
1
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand from...
262
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from di...
32
"""simple docstring""" import enum import shutil import sys __lowerCAmelCase , __lowerCAmelCase : List[str] =shutil.get_terminal_size() __lowerCAmelCase : Union[str, Any] ={"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""} class ...
32
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 __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) ->...
67
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import j...
83
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer a__: Optional[Any] = logging.get_logger(__name__) a__: Tuple = {'vocab_file': 'vocab.json', 'me...
368
def UpperCamelCase__( UpperCamelCase__ : int = 1_00 )->int: A__ = (n * (n + 1) // 2) ** 2 A__ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F"{solution() = }")
39
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 __A : Tuple = logging.get_logger(__name__) ...
33
"""simple docstring""" 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 .....
260
0
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 SPIECE_UNDERLINE, logging _UpperCAmelCase : Any = logging.get_logger(__name__...
363
def UpperCAmelCase__ ( ): lowercase :List[str] = 0 for i in range(1, 1001 ): total += i**i return str(lowerCamelCase )[-10:] if __name__ == "__main__": print(solution())
158
0
"""simple docstring""" import numpy as np from transformers import Pipeline def __A ( a_ :str) -> int: __a : int = np.max(A__ , axis=-1 , keepdims=A__) __a : Any = np.exp(outputs - maxes) return shifted_exp / s...
160
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class __lowe...
205
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__lowercase ) class lowercase_ ( __lowercase ): UpperCamelCase_ : str = field(default="ima...
278
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs if is_torch_available(): import torch i...
278
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def SCREAMING_SNAKE_CASE_ ( __magic_name__ : List[str] , __magic_name__ : str=False ) -> Union[str, Any]: """simple docstring""" UpperCamelCase :Lis...
38
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.config...
125
0
"""simple docstring""" import json import sys def lowerCamelCase__ ( __snake_case, __snake_case ) -> Union[str, Any]: """simple docstring""" with open(__snake_case, encoding='''utf-8''' ) as f: _UpperCamelCase = json.lo...
100
"""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 = { """facebook/xlm-rober...
100
1
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def a_ ( lowerCamelCase : Union[str, Any] , lowerCamelCase : Tuple , lowerCamelCase : Optional[Any] , lowerCamelCase : Any , low...
4
def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ ): lowerCamelCase_ = [0 for i in range(r + 1 )] # nc0 = 1 lowerCamelCase_ = 1 for i in range(1 , n + 1 ): # to compute current row from previous row. lowerCamelCase_ = min(lowerCamelCase__ , lo...
19
0
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowercase__ ( UpperCamelCase_ , UpperCamelCase_): @register_to_config def __init__( sel...
353
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def A ( _lowercase ): return (data["data"], data["target"]) def ...
258
0
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCAmelCase ( lowercase_ ): '''simple docstrin...
121
'''simple docstring''' def __lowerCamelCase ( __snake_case : int, __snake_case : int, __snake_case : list[list[int]] ) -> int: """simple docstring""" def update_area_of_max_square(__snake_case : int, __snake_case : int ) -> in...
134
0
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common impo...
363
"""simple docstring""" from typing import Any class a : """simple docstring""" def __init__( self: List[Any] , UpperCamelCase: Any ): """simple docstring""" A__ = data A__ = None ...
69
0
def _UpperCamelCase ( lowercase__ = 10 , lowercase__ = 1000 , lowercase__ = True ): assert ( isinstance(lowercase__ , lowercase__ ) and isinstance(lowercase__ , lowercase__ ) and isinstance(lowercase__ , ...
9
import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__=1000 ): '''simple docstring''' if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd lowercase = n - 1 ...
101
0
"""simple docstring""" import os import jsonlines import numpy as np from tqdm import tqdm _A = 20_48 _A = 40_96 _A = 42 _A = os.environ.pop("""PROCESS_TRAIN""", """false""") _A = {"""null""": 0, """short""": 1, """long""": 2, """yes""": 3, """no...
363
"""simple docstring""" _A = range(2, 20 + 1) _A = [10**k for k in range(ks[-1] + 1)] _A = {} def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ) -> int: UpperCAmelCase__ : List[str] = sum(a_i[j] for j in...
166
0
import string import numpy def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) -> int: return b if a == 0 else greatest_common_divisor(b % a , __UpperCAmelCase) class __snake_case : '''simple docstring''' lowerCAmelCase__...
111
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResamplin...
201
0
def snake_case ( snake_case__ :str) -> list: if n_term == "": return [] _A = [] for temp in range(int(snake_case__)): series.append(F'''1/{temp + 1}''' if series else """1""") return series if __name__ == "__main__": ...
81
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FNetCo...
81
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer f...
165
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMix...
165
1
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalD...
368
"""simple docstring""" from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf...
30
0
a__: Tuple = 9.8_06_65 def UpperCamelCase__( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float = g )->Dict: if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) ...
193
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase__ : def __init__( self ): """simple docstring""" lowercase_ : int = ...
93
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import Autoencod...
359
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators ...
313
0
from functools import lru_cache @lru_cache def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int) -> int: '''simple docstring''' if num < 0: raise ValueError("Number should not be negative.") return 1 if num in (0, 1) else num * facto...
232
from __future__ import annotations import math lowercase : Any = '2020.9.26' lowercase : Union[str, Any] = 'xcodz-dot, cclaus, dhruvmanila' def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCas...
232
1
'''simple docstring''' import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base impor...
104
'''simple docstring''' from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar a_ : Optional[Any] = TypeVar("T") def _A (lowerCAmelCase__ :int ) -> int: '''simple docstring''' r...
104
1
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterM...
19
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tok...
64
0
from math import asin, atan, cos, radians, sin, sqrt, tan snake_case : Optional[Any] = 6378137.0 snake_case : str = 6356752.314245 snake_case : int = 6_37_81_37 def __lowercase ( __lowerCAmelCase : float , __lowerCAmelCase ...
109
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
1
"""simple docstring""" import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowerCAmelCase ( pl.LightningModule ): '''simple docstring''' def __init__( s...
45
"""simple docstring""" lowercase_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def lowercase ( lowerCAmelCase__ : bytes ) -> bytes: # Make sure the supplied data is a bytes-like object if not isinstance(lowerCAmelCase__ , lowerCAmel...
45
1
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: A__ = [True] * limit A__ = False A__ = False A__ = True for i in range(3 , int(limit**0.5 + 1 ) , 2 ): A__ = i * 2 whi...
230
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/...
230
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class a ( lowercase__ ): __lowerCAmelCase : Dict = (DDPMScheduler,) def __lowerCamelCase ( self :Tuple ,**__lowercase :Union[str, Any] ): ...
230
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : Optional[int] = { 'facebook/mask2former-swin-small-coco-instance': ( 'https://huggingfa...
32
0
'''simple docstring''' import os def UpperCAmelCase_ (__a : str = "input.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(__a ) , __a ) ) as input_file: _a : List[str] = [ [int(__a ) for element in line.split(',' )...
5
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoi...
5
1
"""simple docstring""" from __future__ import annotations class lowerCAmelCase_ : """simple docstring""" def __init__( self , lowerCAmelCase , lowerCAmelCase ): """simple docstring""" snake_case = text, pattern snake_cas...
150
"""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_chan...
213
0
'''simple docstring''' import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, ...
190
'''simple docstring''' import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenize...
190
1
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, re...
170
from __future__ import annotations import math def lowerCAmelCase_ ( _lowercase : int) -> bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negati...
170
1
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _A ( ): """simple docstring""" __lowercase =9 __lowercase =[ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], ...
48
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =SwinConfig(image_size=192 ) ...
48
1
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
268
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class UpperCamelCase_ : def __init__( self : str ) -> Dict: UpperCAmelCase_ : List[Any] = "" UpperCAmelCase_ : int = ""...
268
1
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def lowercase( UpperCamelCase...
368
from ....configuration_utils import PretrainedConfig from ....utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) # TODO: upload to AWS _SCREAMING_SNAKE_CASE = { """yjernite/retribert-base-uncased""": ( """https://huggingface.co/yjernite/retribert-base-unca...
165
0
'''simple docstring''' from __future__ import annotations def a_ ( _lowerCAmelCase ,_lowerCAmelCase ) -> list[str]: if nth_term == "": return [""] __lowerCamelCase : Any = int(__UpperCamelCase ) __lowerCamelCase ...
208
'''simple docstring''' import datasets from .evaluate import evaluate SCREAMING_SNAKE_CASE__ = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n ...
321
0
'''simple docstring''' def _a ( _lowercase : list[int] ): '''simple docstring''' __UpperCAmelCase : Optional[int] = [] if len(_lowercase ) == 1: return [nums.copy()] for _ in range(len(_lowercase ) ): ...
369
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, S...
240
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase : str ={ """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", ...
237
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def UpperCamelCase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str = "cpu" , lowerCAmelCase__ : Union[str, None] = None ) -> None: ...
224
0
from manim import * class UpperCamelCase__ ( __lowercase ): def lowerCAmelCase (self : List[str] ): __a : Union[str, Any] = Rectangle(height=0.5 , width=0.5 ) __a : Union[str, Any] = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) ...
353
import argparse import os import re import packaging.version lowercase__ ='examples/' lowercase__ ={ 'examples': (re.compile(R'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(R'^__version__\s+=\s+"([^"]+)"\s*$', re.MULTILINE), '__ve...
90
0
"""simple docstring""" import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_...
45
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 a_ :Optional[Any] = logging.getLogger(__n...
277
0
import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import Data...
350
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) __a = logging.getLogger() def lowerCamelCase__ ...
235
0
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import float...
109
"""simple docstring""" import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _snake_case ( *UpperCamelCase : str , UpperCamelCase : Optional[Union[Dict, Any]] = None , UpperCamelCase : Tuple=True , UpperCamelCase ...
109
1
from __future__ import annotations def UpperCamelCase_( _snake_case : list[int] , _snake_case : int , _snake_case : int , _snake_case : int ): """simple docstring""" if (direction == 1 and array[indexa] > array[indexa]) or (...
308
import os def UpperCamelCase_( _snake_case : str = "input.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(_snake_case ) , _snake_case ) ) as input_file: __a =[ [int(_snake_case ) for element i...
308
1
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device _lowerCamelCase : Optional[int] = Fal...
167
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import ...
167
1
'''simple docstring''' def __UpperCAmelCase ( a_: list[int] ): if not numbers: return 0 if not isinstance(a_, (list, tuple) ) or not all( isinstance(a_, a_ ) for number in numbers ): raise ValueError("numbers must be an iterable of integers" ) ...
17
'''simple docstring''' import baseaa def __UpperCAmelCase ( a_: str ): return baseaa.baaencode(string.encode("utf-8" ) ) def __UpperCAmelCase ( a_: bytes ): return baseaa.baadecode(a_ ).decode("utf-8" ) if __name__ == "__main__": ...
17
1
import os def UpperCAmelCase_ ( __snake_case = "input.txt" ) -> int: """simple docstring""" with open(os.path.join(os.path.dirname(__snake_case ) , __snake_case ) ) as input_file: _lowercase =[ [int(__snake_case ) for element in lin...
5
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from transfor...
5
1
class snake_case__ : def __init__( self , lowerCAmelCase__ , lowerCAmelCase__=None , lowerCAmelCase__=None ) -> Tuple: __magic_name__ : int = data __magic_name__ : Dict = previous __magic_name__ ...
138
__magic_name__: List[Any] = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __magic_name__: Dict = [{"type": "code", "content": INSTALL_CONTENT}...
138
1
"""simple docstring""" import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class _SCREAMING_SNAKE_CASE ( A__ ): def __init__( self , __A ...
84
'''simple docstring''' a__ : Union[str, Any] = [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: '''simple docstring''' UpperCamelCase__ = 0 while number: # In...
80
0
'''simple docstring''' import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import ...
360
'''simple docstring''' from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import f...
337
0
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline _a = datasets.utils.logging.get_logger...
322
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _a = '''.''' # Internal TensorFlow ops that can be s...
322
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_tes...
36
def lowerCAmelCase__ ( _a : float , _a : float ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": ...
36
1
'''simple docstring''' import math import sys import cva import numpy as np def _lowerCAmelCase ( _UpperCamelCase : Optional[int] , _UpperCamelCase : List[Any] ) -> Any: """simple docstring""" _SCREAMING_SNAKE_CASE =math.sqrt(snake_case__ ...
47
"""simple docstring""" import os 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_ : List[Any] = logging.get_logger(__na...
165
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
276
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging A : Optional[Any] = logging.get_logger(__name__) A : List[str] = { '''huggingface/time-series-transformer-tourism-monthly''': ( '''https://hugging...
276
1
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import ca...
48
'''simple docstring''' import string from math import logaa def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> int: snake_case__ : List[str] = document.translate( str.maketrans("""""" , """""" , string.punctuation ) ).replace("""\n""" ...
35
0
import math def lowerCAmelCase_ (lowerCAmelCase__: int ): """simple docstring""" assert isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: #...
82
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel a : Optional[int] = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.self', 'se...
82
1
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ......
109
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
111
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils impo...
152
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailab...
152
1
import argparse import copy def _A ( _lowercase ) -> List[Any]: """simple docstring""" __UpperCamelCase = {} with open(__snake_case ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: ...
310
'''simple docstring''' import requests from bsa import BeautifulSoup def __lowerCamelCase ( __snake_case : str, __snake_case : dict ) -> str: """simple docstring""" A__ : Optional[Any] =BeautifulSoup(requests.get(__snake_case, params=__s...
134
0
"""simple docstring""" import unittest from transformers import DonutProcessor _UpperCamelCase: Any = 'naver-clova-ix/donut-base' class a__ ( unittest.TestCase ): def lowercase ( self : Optional[Any] ) -> Tuple: ...
53
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if ...
53
1