code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mo...
693
from __future__ import annotations import math def _A ( __snake_case :int , __snake_case :int , __snake_case :bool , __snake_case :list[int] , __snake_case :float ) -> int: """simple docstring""" if depth < 0: raise ValueError("Depth cannot be les...
693
1
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_channel_dimension_format, ) f...
719
lowerCAmelCase_ = [ [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 ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ) -> int...
470
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrajectoryTrans...
532
"""simple docstring""" import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE__ = logging.getLogger(__...
532
1
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants UpperCamelCase = 300 # TEMPERATURE (unit = K) def lowerCAmelCase ( UpperCamelCase_: float , UpperCamelCase_: float , UpperCamelCase_: float ...
716
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSche...
612
0
'''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...
697
'''simple docstring''' import unittest from transformers import DonutProcessor __lowerCAmelCase ="naver-clova-ix/donut-base" class _snake_case ( unittest.TestCase ): """simple docstring""" def __SCREAMING_SNAKE_CASE ( self ) -> Optional[Any]: a_ = D...
697
1
def _lowercase ( _UpperCAmelCase ) -> int: if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] lowerCamelCase ...
269
from abc import ABC, abstractmethod from argparse import ArgumentParser class __A ( a ): @staticmethod @abstractmethod def _snake_case ( UpperCAmelCase_ ): raise NotImplementedError() @abstractmethod def _snake_case ( self ): rai...
269
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase__ : Dict = { 'configuration_gpt_bigcode': ['GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTBigCodeConfig'], } try: if no...
98
'''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...
98
1
from __future__ import annotations def A_ ( __a : list[int] ): """simple docstring""" return len(set(__a ) ) == len(__a ) if __name__ == "__main__": import doctest doctest.testmod()
712
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCAmelCase = 299_792_458 # Symbols UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase = symbols("""ct x y z""") def A_ ( __a ...
351
0
import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available, ) from . import BaseTran...
537
import warnings 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 SCREAMING_SNAKE_CASE_ ( __lowerCAmelCase ): __l...
537
1
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def _lowerCAmelCase ( ): """simple docstring""" raise RuntimeError("CUDA out of memory." ) class _SCREAM...
709
# 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 appli...
447
0
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def _UpperCamelCase (_lowerCamelCase : str , _lowerCamelCase : Optional[int] , _lowerCamelCase : Optional[Any] )-> Union[str, A...
24
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFM...
351
0
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __lowercase ( __lowerCAmelCase : Optional[Any] , __lowerCAmelCase : int , __lowerCAmelCase : List[Any] ): a_...
657
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
1
import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version SCREAMING_SNAK...
79
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test...
591
0
"""simple docstring""" from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer from .base import PipelineTool class UpperCamelCase_ ( a_ ): '''simple docstring''' _A : Dict = 'philschmid/bart-large-cnn-samsum' _A : Optional[Any] = ( 'This is...
716
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Any = logging.get_logger(__name__) lowerCAmelCase_ : Any = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/...
378
0
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : int = 200 ): lowercase = [1, 2, 5, 10, 20, 50, 100, 200] lowercase = [0] * (pence + 1) lowercase = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(lowercase...
588
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowercase_ : Any = { '''linear''': PIL.Image.Resampling.BILINEAR, ...
588
1
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone i...
702
'''simple docstring''' from sklearn.metrics import mean_squared_error import datasets a : Union[str, Any] = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. ...
672
0
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def a_ ( lowerCAmelCase_ : int, lowerCAmelCase_ : Optional[int], lowerCAmelCase_ : int ): ...
53
from jiwer import compute_measures import datasets A_: Optional[int] = '\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evaluation measures for...
398
0
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", "xlnet-large-cased...
718
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowercase ( A__ , A__ ): '''simple do...
391
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase_ : Any = { '''configuration_blip''': [ '''BLIP_PRETRAINED_...
115
lowercase = 8.314_4598 def __lowerCAmelCase ( UpperCAmelCase__ : float , UpperCAmelCase__ : float ) -> float: if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <= 0: raise Ex...
272
0
from math import isqrt def _lowercase ( UpperCAmelCase_): """simple docstring""" snake_case__ : Optional[Any] = [True] * max_number for i in range(2 , isqrt(max_number - 1) + 1): if is_prime[i]: for j in range(i**2 , UpperCAmelCase_ , Upp...
127
def _lowercase ( UpperCAmelCase_): """simple docstring""" if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""") for cell_n in range(1 , len(grid[0])): grid[0][cell_n] += grid[0][cell_n - 1] snake_case__ : L...
127
1
def lowerCAmelCase( __lowerCamelCase ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__lowerCamelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("""doctest""").testmod()
559
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # no...
559
1
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets UpperCAmelCase = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For binary (two class...
342
"""simple docstring""" import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """post_extract_proj""":...
342
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase : Dict = { 'configuration_mctct': ['MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MCTCTConfig'], 'feature_extraction_mctct': ['MCTCT...
50
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def UpperCamelCase__ ( lowercase__ : str , lowercase__ : List[Any] , lowercase__ : int ): snake_case : Tuple = 0 if start < end: snake_case ...
134
0
'''simple docstring''' # Imports import numpy as np class __a : def __init__( self : Dict ,lowerCamelCase : Optional[Any]=None ,lowerCamelCase : Dict=None ,lowerCamelCase : Optional[int]=None ,lowerCamelCase : Tuple=None ,lowerCamelCase : int=None ...
13
'''simple docstring''' from __future__ import annotations from collections.abc import Callable a = list[list[float | int]] def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase ) -> Matrix: '''simple docstring''' __SCREAMING_SNAKE_CASE ...
13
1
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _snake_case : Dict = logging.get_logger(__name__) _snake_case : Union[str, Any] = { "vocab_file": ...
81
from PIL import Image def A__ ( _a : Image , _a : float ): '''simple docstring''' def brightness(_a : int ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError("""level must be between -255.0 (black) and...
385
0
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _lowercase : List[str] ...
412
from __future__ import annotations from collections.abc import MutableSequence class lowerCAmelCase_ : '''simple docstring''' def __init__( self , lowerCamelCase , lowerCamelCase ): '''simple docstring''' if len(lowerCamelCase ) != degree + 1: raise V...
412
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : Any = { 'configuration_owlvit': [ 'OWLVIT_P...
73
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_ver...
573
0
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class lowerCamelCase__( __lowerCamelCase): ...
80
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'bert-base-uncased': 'https://hugging...
80
1
import datasets from .evaluate import evaluate _lowerCamelCase : List[str] = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, journal={arXiv preprint...
686
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def a_ ( ) -> Optional[Any]: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with ...
686
1
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # fu...
319
'''simple docstring''' import math class UpperCAmelCase__ : """simple docstring""" def __init__( self : List[str] ,_a : Tuple=0 ): # a graph with Node 0,1,...,N-1 '''simple docstring''' _a : List[Any] = n _a : int = [ ...
319
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], 'token...
5
"""simple docstring""" SCREAMING_SNAKE_CASE__ : int =6_5521 def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ) ->int: _lowerCamelCase : Union[str, Any] = 1 _lowerCamelCase : List[str] = 0 for plain_chr in plain_text: _lowerCamelCase : Di...
434
0
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging ...
214
def _A ( __snake_case :list[int] ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) __SCREAMING_SNAKE_CASE = sum(__snake_case ) / len(__snake_case ) # Calculate t...
214
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : Dict = { """configuration_whisper"...
545
from __future__ import annotations from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : """simple docstring""" __UpperCAmelCase = 42 __UpperCAmelCase = None __UpperCAmelCase = None def UpperCAmelCase__( ...
576
0
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingPipeline 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 ..pipeline_par...
491
"""simple docstring""" import pytest _snake_case = '''__dummy_dataset1__''' _snake_case = ''' import json import os import datasets REPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/" URLS = {"train": REPO_URL + "wikiann-bn-train.jso...
491
1
"""simple docstring""" def lowercase__( __SCREAMING_SNAKE_CASE : int ): if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): raise TypeError('only integers accepted as input' ) else: lowercase_ : Union[str, Any] = str(abs(__SCREAMI...
425
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __SCREAMING_SNAKE_CASE =TypeVar("T") class UpperCamelCase ( Generic[T] ): def __init__( self ,__UpperCamelCase ) -> Any: ...
425
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": UpperCAmelCase = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input('''Search: '''))) print('''Googli...
720
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf...
475
0
from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_pipeline_mixin impor...
348
from math import log from scipy.constants import Boltzmann, physical_constants __SCREAMING_SNAKE_CASE : int = 3_00 # TEMPERATURE (unit = K) def UpperCAmelCase__ ( __magic_name__ : float , __magic_name__ : float , __magic_name__ : float , ): '''simple docstring''...
348
1
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_di...
67
"""simple docstring""" from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError("""To use the rich extension, install rich with `pip install rich`""")
67
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: ...
43
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( __snake_case ): SCREAMING_SNAKE_CASE_ : List[str] = (DDPMScheduler,) def lowercase_ ( self : List...
346
0
"""simple docstring""" import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VO...
120
"""simple docstring""" from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_I...
120
1
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _A ( _a ): '''simple docstring''' __...
36
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from s...
303
0
import functools def _a ( lowercase__ : str , lowercase__ : str ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[int] = len(lowercase__ ) SCREAMING_SNAKE_CASE__ : Optional[Any] = len(lowercase__ ) @functools.cache def min_dist...
700
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
636
0
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
import unittest import numpy as np from transformers import AlbertConfig, 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 jax.numpy as j...
254
0
"""simple docstring""" import numpy as np import datasets UpperCAmelCase : Dict = "\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean di...
100
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> int: '''simple docstring''' while a != 0: lowercase_ , lowercase_ = b % a, a return b def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerC...
100
1
"""simple docstring""" 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 ......
338
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from...
338
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : List[Any] = logging.get_logger(__name__) _UpperCAmelCase : Tuple = { "facebook/timesformer": "https://huggingface.co/facebook/timesformer/resolve/main/config.json", } class __lower...
453
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientState, Pa...
453
1
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamel...
6
"""simple docstring""" from bisect import bisect from itertools import accumulate def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): UpperCamelCase : Dict = sorted(zip(SCREA...
102
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 from ..auto import CONFIG_MAPPING UpperCAmelCase__ : str = logging.ge...
676
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('repo_id' , ['canonical_dataset_name', 'org-name/dataset-name'] ) @pytest.mark.parametrize('path' , ['filename.csv', 'filename with blanks.csv'] ) @pytest....
676
1
"""simple docstring""" class lowerCamelCase__ : def __init__( self : Dict , A_ : int , A_ : Dict ): '''simple docstring''' __lowercase = name __lowercase = val def __str__( self ...
616
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ ...
616
1
'''simple docstring''' def __lowerCAmelCase ( snake_case__ , snake_case__ ): _validate_point(snake_case__ ) _validate_point(snake_case__ ) if len(snake_case__ ) != len(snake_case__ ): raise ValueError("Both points must be in the same n-dimensional space...
399
'''simple docstring''' import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTeste...
399
1
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStrea...
52
from __future__ import annotations import time import numpy as np A__ = [8, 5, 9, 7] A__ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] A__ = [ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, 5, 3, 0], [3, 0, 3...
166
0
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow ...
218
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def snake_case_ (__A : str = "" ) -> dict[str, float]: __lowerCAmelCase : str = url or """https://www.imdb.com/chart/top/?ref_=nv_mv_250""" __lowerCAmelCase : ...
218
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Tuple = {'configuration_mmbt': ['MMBTConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opti...
98
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common im...
462
0
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_...
108
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ......
108
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Optional[int] = logging.get_logger(__name__) _a : Tuple = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", } class _UpperCAm...
145
from collections import Counter from timeit import timeit def snake_case__ ( UpperCAmelCase : str = "" , ): return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def snake_case__ ( UpperCAmelCase : str = "" ...
145
1
'''simple docstring''' import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, ...
692
'''simple docstring''' def lowerCAmelCase_ ( __A : int = 1_00 ): '''simple docstring''' snake_case: List[str] = n * (n + 1) * (2 * n + 1) / 6 snake_case: List[Any] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) ...
692
1
'''simple docstring''' from PIL import Image def A_( A : Image , A : int): UpperCamelCase = (259 * (level + 255)) / (255 * (259 - level)) def contrast(A : int) -> int: return int(128 + factor * (c - 128)) return img.point...
3
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensi...
3
1
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def A_ ( __a : List[Any] , __a : List[str] , __a : int , __a : List[str] ): """simple docstring""" a__ = { """en""": """Machine learning is great, isn't it?"""...
351
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_al...
351
1
"""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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.se...
594
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(...
594
1
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__n...
264
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETRAINED_CONFIG...
264
1
"""simple docstring""" __snake_case : Optional[Any] = 8.314_462 # Unit - J mol-1 K-1 def _lowercase ( __snake_case ,__snake_case ,__snake_case ) -> float: if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("Invalid inputs. Enter positive v...
293
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionCon...
293
1
from __future__ import annotations from typing import Any class lowerCamelCase__ : """simple docstring""" def __init__( self , snake_case ): '''simple docstring''' UpperCamelCase__ = num_of_nodes UpperCamelCase__ = [] ...
185
from __future__ import annotations import numpy as np def UpperCamelCase_( _A :list[float] )-> Union[str, Any]: return np.maximum(0 , _A ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
185
1
import os from distutils.util import strtobool def snake_case__ ( lowercase , lowercase ): for e in env_keys: lowerCAmelCase_: Optional[Any] = int(os.environ.get(lowercase , -1 ) ) if val >= 0: return val return default def snake_case__ ( lowerc...
613
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import Mo...
613
1
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequen...
710
'''simple docstring''' import unittest import numpy as np from transformers import AlbertConfig, 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 jax....
466
0
'''simple docstring''' import argparse from collections import defaultdict import yaml lowerCamelCase_ = """docs/source/en/_toctree.yml""" def SCREAMING_SNAKE_CASE_ ( __A : Optional[Any] ) -> str: _SCREAMING_SNAKE_CASE = defaultdict(__A ) _SCREAMING_SNAKE_...
418
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class lowercase ( UpperCAmelCase_ ): """simple docstring""...
165
0
'''simple docstring''' import requests a : str = """YOUR API KEY""" def __lowerCamelCase ( _lowercase , _lowercase = giphy_api_key ) -> list: UpperCAmelCase : Union[str, Any] = """+""".join(query.split() ) UpperCAmelCase : List[Any] ...
672
'''simple docstring''' import math def __lowerCamelCase ( _lowercase ) -> bool: assert isinstance(_lowercase , _lowercase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
672
1
'''simple docstring''' import os _SCREAMING_SNAKE_CASE : Optional[Any] = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 1_00, "D": 5_00, "M": 10_00} def _UpperCamelCase ( UpperCamelCase__ ): """simple docstring""" __magic_name__ : ...
436
'''simple docstring''' def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" return "\n".join( F"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(mu...
436
1
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel,...
623
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when s...
623
1
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCamelCase_ ( unittest.TestCase ): def __a ( self : List[Any] ): lowerCamelC...
364
import argparse import os import re import packaging.version __a : Tuple = "examples/" __a : Any = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$"...
637
0
def snake_case_ ( __lowercase = 5_0 ): UpperCAmelCase_ : Optional[int] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - til...
721
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
641
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Optional[Any] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_...
438
"""simple docstring""" import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_co...
438
1
'''simple docstring''' import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCamelCase ( UpperCAmelCase__ : Dict , UpperCAmelCase__ : List[str]=None ) -> Tuple: lowercase_ ...
718
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( UpperCAmelCase__ : list , UpperCAmelCase__ : int | None = None , UpperCAmelCase__ : int | None = None ) -> None: if start is None: lowercase_ : Any = 0 ...
30
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node SCREAMING_SNAKE_CASE__ : Any = 4 SCREAMING_SNAKE_CASE__ : Optional[Any] = ...
85
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class A ( __UpperCAmelCase ): lowerCamelCase : U...
325
0
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase = " " ): '''simple docstring''' _lowerCAmelCase : Dict = [] _lowerCAmelCase : List[Any] = 0 for index, char in enumerate(_lowerCamelCase ): if char...
16
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __UpperCamelCase...
16
1
"""simple docstring""" __lowercase : 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 SCREAMING_SNAKE_CASE ( snake_case, snake_case, snake_case, snake_cas...
564
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Union[str, Any] = { "config...
564
1
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_docstrings.py...
429
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
429
1
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 OptionalDependencyNotAvailable() except O...
639
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, PILImageResampl...
318
0
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common ...
703
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): if number < 0 or shift_amount < 0: raise ValueError("both inputs must be positive integers" ) __snake_case : Dict = str(bin(__lowerCamelCase ) ) binary_number += "0" * shift_...
203
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers....
569
from ...configuration_utils import PretrainedConfig class _UpperCAmelCase ( _lowerCamelCase ): a = '''bert-generation''' def __init__( self , a__=50358 , a__=1024 , a__=24 , a__=16 , a__=4096 , a__="gelu" , a__=0.1 , ...
569
1
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation ...
120
"""simple docstring""" import unittest import numpy as np from datasets import load_dataset 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 ImageProcessingSavingTestMixi...
120
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record SCREAMING_SNAKE_CASE : Optional[Any] = "\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},...
635
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent SCREAMING_SNAKE_CASE : Union[str, Any] = {"UserAgent": UserAgent().random} def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : Dict ): ...
635
1
"""simple docstring""" import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/r...
628
"""simple docstring""" import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, ...
628
1
from __future__ import annotations _lowerCamelCase : str = tuple[int, int, int] _lowerCamelCase : Dict = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase _lowerCamelCase : List[Any] = """ABCDEFGHIJKLMNOPQRSTUVWXYZ"...
352
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, )...
352
1
import os import sys import unittest __lowercase : int = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
315
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowercase : Optional[int] = { '''configuration_chinese_clip''': [ '''CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ChineseCLIPConfig''...
315
1
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class a ( datasets.BuilderConfig ): """simple docstring""" _...
347
'''simple docstring''' from ... import PretrainedConfig lowerCAmelCase__ : Dict = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class a ( SCREAMING_SNAKE_CASE ): """simple docstring""" ...
347
1
'''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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) ...
701
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _lowerCAmelCase ( __A ): """simple docstring""" lowerCamelCase = '''''' lowerC...
385
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __lowercase : Union[str, Any] = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfi...
36
import argparse import hashlib # hashlib is only used inside the Test class import struct class _lowerCAmelCase : def __init__( self : Any , __snake_case : int ): lowerCamelCase :Union[str, Any] = data lowerCamelCase :Optional[int] ...
166
0
'''simple docstring''' import sys from pathlib import Path UpperCamelCase__ : Dict = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import itertools # noqa import json # noqa import os # noqa import unittest #...
703
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def lowerCAmelCase_ ( _l...
178
0
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root...
696
from ...configuration_utils import PretrainedConfig class UpperCamelCase ( snake_case__ ): __UpperCamelCase = """bert-generation""" def __init__( self : Tuple ,_lowerCAmelCase : Union[str, Any]=50_358 ,_lowerCAmelCase : List[Any]=1_024 ,_lowerCAmelC...
524
0
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trainin...
316
from __future__ import annotations import math import random from typing import Any class a__ : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE_ : list[Any] = [] SCREAMING_SNAKE_CASE_ : int = 0 ...
316
1
def lowerCamelCase__ ( _lowercase , _lowercase ): '''simple docstring''' if not len(_lowercase ) == len(_lowercase ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0: raise ValueError('...
30
__a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def lowerCamelCase__ ( _lowercase ): '''simple docstring''' if not isinstance(_lowercase , _lowercase ): UpperCAmelCase_ : Union[str, Any] = f'''a bytes-like object is require...
30
1
"""simple docstring""" import re import string import numpy as np import datasets lowerCAmelCase : Optional[Any] = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ lowerCA...
705
"""simple docstring""" def a__ ( snake_case__ = 1_00_00_00 ) -> int: lowerCamelCase = 1 lowerCamelCase = 1 lowerCamelCase = {1: 1} for inputa in range(2 , snake_case__ ): lowerCamelCase = 0 lowerCamelCase ...
533
0
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowerCAmelCase__ ( _a : int ): snake_case_ : Optional[Any] = os.path.join(args.tf_model_dir , "parameters.json" ) snake_ca...
568
'''simple docstring''' import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class UpperCamelCase__ ( lowercase__ ): """simple docstring""" def A_ ( self , snake_case ): '''simple docstring''' with open...
679
0
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __A : List[Any] = get_tests_dir() ...
334
from __future__ import annotations def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ) -> bool: '''simple docstring''' if len(UpperCamelCase__ ) == 0: return False __lowerCAmelCase = len(UpperCamelCase__ ) // 2 if a_list[midpoint...
334
1
'''simple docstring''' __A : List[Any] = 8.3_14_45_98 def UpperCAmelCase ( lowerCamelCase_ :float , lowerCamelCase_ :float ): '''simple docstring''' if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <= 0: raise Exc...
334
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase ( lowerCamelCase_ :List[Any] , lo...
334
1
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") _snake_case : Optional[Any] = """https://www.google.com/search?q=""" + """ """.join(sys.argv[1:])...
714
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _a ( _SCREAMING_SNAKE_CASE : int ): # A local function to see if a dot lands in the circle. def is_in_circle(_SCREAMING_SNAKE_CASE : float ,...
493
0
'''simple docstring''' def snake_case_ ( __snake_case : Tuple = 100) -> Union[str, Any]: 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() = ...
274
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _lowerCAmelCase = logging.get_logger(__name__) def _snake_case ( __snake_case=None , __snake_case=None ): return field(default_...
10
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 DataLo...
531
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def __lowerCAmelCase (SCREAMING_SNAKE_CASE=...
531
1
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, 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...
46
def _A ( SCREAMING_SNAKE_CASE ): stooge(SCREAMING_SNAKE_CASE ,0 ,len(SCREAMING_SNAKE_CASE ) - 1 ) return arr def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ): if i >= h: return # If first element is smaller than the last then swap them if arr[i...
113
0
"""simple docstring""" def lowercase ( A_ )-> float: '''simple docstring''' if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) a : Union[str, Any] = sum(A_ ) / len(A_ ) # Calculate the average return s...
135
"""simple docstring""" import os def lowercase ( )-> Optional[Any]: '''simple docstring''' a : Optional[int] = os.path.join(os.path.dirname(A_ ) , "num.txt" ) with open(A_ ) as file_hand: return str(sum(int(A_ ) for line in file_ha...
135
1