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 os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import T...
102
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import Ta...
2
0
def _a ( UpperCAmelCase , UpperCAmelCase ) -> float: """simple docstring""" if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: raise ValueError('''Cash flows list cannot be empty''' ) lowerCamelCase__ ...
353
from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Any = logging.get_logger(__name__) _A : int = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class __SCREAMING_SNAKE_CASE ( lowerCAmelCase...
265
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCAmelCase ( __snake_case ): '''simple docstring''...
341
def lowerCAmelCase__ ( ) -> Any: '''simple docstring''' for n in range(1 , 1_0_0_0_0_0_0 ): yield n * (n + 1) // 2 def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Tuple ) -> Any: '''simple docstring''' A__ = 1 A__ ...
68
0
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''xlnet-large-cased''': '...
368
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_ = { '''junnyu/roformer_chinese_small''': '''https://...
59
0
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit,...
115
"""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...
115
1
"""simple docstring""" from __future__ import annotations class UpperCAmelCase_ : '''simple docstring''' def __init__( self , _A , _A ): '''simple docstring''' __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = text, p...
359
from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=UpperCamelCase_ ): '''simple docstring''' UpperCamelCase__ : Optional[int] = ['''speech'''] def __init__( self , *_A , **_A ): '''sim...
118
0
'''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 __UpperCAmelCase = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokeni...
323
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get...
137
0
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`')
189
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...image_p...
189
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 ...
217
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', 'ConvBertOnn...
142
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __a ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection snake_case_ : Dict = len(__a ) snake_case_ : Optional[int] =...
363
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatur...
88
0
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import...
32
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .te...
32
1
def snake_case( __magic_name__ = 10_00 ) -> int: '''simple docstring''' lowercase : int = 1, 1 lowercase : Dict = 2 while True: lowercase : List[Any] = 0 lowercase : str = fa + fa ...
354
import os import sys import unittest lowerCAmelCase_ = 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, fin...
116
0
import argparse from collections import defaultdict import yaml lowerCAmelCase__ = """docs/source/en/_toctree.yml""" def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Any ) -> Any: '''simple docstring''' A__ = defaultdict(lowercase__ ) A__ = [...
68
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler,...
84
0
import itertools import string from collections.abc import Generator, Iterable def A ( lowercase , lowercase ) -> Generator[tuple[str, ...], None, None]: '''simple docstring''' UpperCamelCase = iter(lowercase ) while True: UpperCamelCase = tuple(iterto...
351
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 require_vision from transformers.utils import ...
110
0
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
12
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizer...
265
0
def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : float , _lowerCamelCase : float) -> float: '''simple docstring''' if density <= 0: raise ValueError("Impossible fluid density") if bulk_modulus <= 0: raise ValueError("...
368
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) lowercase : Optional[Any] = pytest.mark.integration @pytest.mark.parametrize(...
151
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[str] ...
105
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tokenization_ta...
59
0
# Copyright (c) 2021-, NVIDIA CORPORATION. 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 ap...
278
from math import factorial def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> int: """simple docstring""" if n < k or k < 0: raise ValueError('''Please enter positive integers for n and k where n >= k''' ) return factorial(_UpperCamelCase ) // (factorial(_UpperCam...
278
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint....
124
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class lowerCamelCase (SCREAMING_SNAKE_CASE__ ,...
118
0
import math import os import sys def SCREAMING_SNAKE_CASE_ ( __A : Optional[int] ) -> Dict: _SCREAMING_SNAKE_CASE = '' try: with open(__a , "rb" ) as binary_file: _SCREAMING_SNAKE_CASE = binary_file.read() for dat in data: _SCREAMING_SNAKE_CASE = ...
350
'''simple docstring''' import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase_ = { ...
111
0
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class __a ( A__ , A__ )...
189
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import Au...
189
1
from math import ceil def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase = 1_001 ) -> int: '''simple docstring''' lowerCAmelCase : Optional[Any] = 1 for i in range(1, int(ceil(n / 2.0 ) ) ): lowerCAmelCase : str = 2 * i + 1 lowerC...
363
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Union[str, Any] = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfi...
323
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : str = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfig'],...
169
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class UpperCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def ...
88
0
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def a ( SCREAMING_SNAKE_CASE_ : Optional[Any] ): """simple docstrin...
371
def a ( SCREAMING_SNAKE_CASE_ : int = 5_0 ): """simple docstring""" UpperCamelCase : List[str] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , ro...
315
0
'''simple docstring''' import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer SCREAMING_SNAKE_CASE_: Union[str, Any] =logging.getLogger(__name__) def lowerCAmelCase_ ( ) -> Union[str, Any]: '''simple docstring''' ...
1
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=SCREAMING_SNAKE_CASE__ ): '''simple docstring''' __lowerCamelCase : List[str] = ["torch", "transformers", "onnx"] def __init__( self, *lowerCamelCase__, **lowerCam...
116
0
def __magic_name__ ( __a : list ): '''simple docstring''' UpperCamelCase__ = len(__a ) for _ in range(__a ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: UpperCamelCase__ , UpperCamelCas...
368
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_image_inputs if is_torch_available(): import torch ...
178
0
def lowerCAmelCase__(__snake_case ) -> Union[str, Any]: '''simple docstring''' lowerCamelCase__ = generate_pascal_triangle(__snake_case ) for row_idx in range(__snake_case ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=''' ...
209
from __future__ import annotations def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = 0 lowercase__ = len(SCREAMING_SNAKE_CASE ) - 1 while i < j: if nums[i] + nums[j] == target: ...
110
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Tuple = logging.get_logger(__name__) snake_case : Union[str, Any] = { "bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json", } ...
357
from typing import Any class _snake_case : def __init__( self , _a ): __magic_name__ : Union[str, Any] = data __magic_name__ : str = None class _snake_case : def __init__( self ): __magic_name__ : List[str] ...
41
0
"""simple docstring""" from __future__ import annotations def snake_case_ ( A_ : Optional[int], A_ : int, A_ : Union[str, Any] ): '''simple docstring''' if len(UpperCAmelCase_ ) == 0: raise ValueError('''find_max() arg is an ...
72
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer...
151
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE__ ) class __UpperCAmelCase( SCREA...
150
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transf...
150
1
import os from collections.abc import Iterator def __UpperCamelCase ( _A = "." ): for dir_path, dir_names, filenames in os.walk(_A ): lowerCAmelCase_ = [d for d in dir_names if d != '''scripts''' and d[0] not in '''._'''] for filename in filenames: ...
278
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _A ): lowerCAmelCase_ = 384 ...
278
1
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pip...
360
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available __snake_case : Any = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONF...
136
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def UpperCamelCase_( snake_case : Optional[int] ): '''simple docstring''' if ( (cp >= 0X4E00 and cp <= 0X9FFF) ...
85
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __UpperCAmelCase : str = TypeVar("T") def A__ ( SCREAMING_SNAKE_CASE__) -> int: return (position - 1) // 2 def A__ ( SCREAMING_SNAKE_CASE__) -> ...
111
0
import os import pytest from transformers.dynamic_module_utils import get_imports lowerCamelCase_ = """ import os """ lowerCamelCase_ = """ def foo(): import os return False """ lowerCamelCase_ = """ def foo(): def bar(): if True: ...
14
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def lowerCamelCase ( a_ , a_ , a_ , a_ , a_ ) -> List[Any]: # load base model lowerCAmelCase_ = StableD...
14
1
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def _UpperCamelCase ( lowercase__ = "laptop" ): __SCREAMING_SNAKE_CASE : List[str] = F'''https://www.amazon.in/laptop/s?k={product}''' __SCREAMING_SNAKE_CAS...
9
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import Model...
323
0
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging...
55
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
1
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @requi...
170
"""simple docstring""" from collections.abc import Callable def _snake_case ( _snake_case : Callable[[float], float] , _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' _A = a _A ...
315
0
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we h...
351
'''simple docstring''' def A (__lowerCamelCase :list[int] , __lowerCamelCase :list[int] ): # Check if the input is valid if not len(__lowerCamelCase ) == len(__lowerCamelCase ) == 3: raise ValueError("""Please enter a valid equation.""" ) if equationa[0] == equation...
229
0
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ ): return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = number while duplicate > 0...
100
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def __UpperCAmelCase ( a_ , a_ , a_ , a_ , a_): snake_case_ = np.array([[...
178
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ : int = logging.get_logger(__name__) snake_case_ : Union[str...
359
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class lowercase__ ( lowercase ): @staticmethod @abstractmethod def UpperCamelCase_ ( lowerCamelCase__ : ArgumentParser ): '''simple docstring''' raise...
236
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case = '''▁''' __snake_case = {'''vocab_file''': '''spiece.mo...
203
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device _A : Union[str, Any] =False class _lowe...
41
0
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class _lowerCamelCase ( a_ ): # to overwrite at feature extractactor spe...
212
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational...
212
1
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput cla...
150
"""simple docstring""" from __future__ import annotations from cmath import sqrt def lowerCAmelCase__ ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : int ) -> tuple[complex, complex]: """simple docstring""" if a ==...
150
1
import comet # From: unbabel-comet import torch import datasets UpperCamelCase__ =datasets.logging.get_logger(__name__) UpperCamelCase__ ='\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon},\n title = {Unbabel\'s...
359
from timeit import timeit def lowerCamelCase__ (__lowerCamelCase ): if number < 0: raise ValueError("the value of input must not be negative" ) _SCREAMING_SNAKE_CASE : str = 0 while number: number &= number - 1 result += 1 return...
325
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 lowercase_ = datasets.utils.logging.get...
7
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np UpperCAmelCase : Union[str, Any] = re.compile(r"\b(a|an|the)\b", re.UNICODE) UpperCAmelCase : Optional[Any] = None def _SCREAMING_...
136
0
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def UpperCamelCase ( ): snake_case : Optional[Any] = [randint(-1000 , 1000 ) for i in range(10 )] snake_case : Any = r...
10
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = """▁""" __lowerCam...
10
1
import os import pytest from transformers.dynamic_module_utils import get_imports _lowerCamelCase : Any = """ import os """ _lowerCamelCase : Optional[int] = """ def foo(): import os return False """ _lowerCamelCase : List[Any] = """ def foo(): def ...
14
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig 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 ...
14
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "andreasmadsen/efficient_...
83
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax ...
83
1
'''simple docstring''' import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, ...
55
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCase...
55
1
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENI...
350
"""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 impo...
58
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowerCAmelCase : str = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TrOCR...
13
import numpy as np from transformers import Pipeline def lowerCAmelCase__(__snake_case ) -> Tuple: '''simple docstring''' lowerCamelCase__ = np.max(__snake_case ,axis=-1 ,keepdims=__snake_case ) lowerCamelCase__ = np.exp(outputs - maxes ...
209
0
'''simple docstring''' import random def UpperCAmelCase_ ( __lowercase : int ) -> bool: '''simple docstring''' _UpperCAmelCase = num - 1 _UpperCAmelCase = 0 while s % 2 == 0: _UpperCAmelCase = s // 2 ...
368
'''simple docstring''' from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import...
156
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_config...
17
class lowercase : def __init__( self , snake_case , snake_case , snake_case ): snake_case_ = name snake_case_ = value snake_case_ = weight def __repr__( self ): return F'''{self.__class_...
285
0
from math import ceil def lowerCamelCase__ ( a__ : int , a__ : Any ) -> int: UpperCamelCase_ = list(range(0 , a__ ) ) UpperCamelCase_ = [item for sublist in list(device_map.values() ) for item in sublist] # Duplica...
371
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCamelCase__ ( a__ : Dict , a__ : Dict=None ) -> Union[str, Any]: UpperCamelCase_ = None if token is n...
261
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging...
330
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
330
1
'''simple docstring''' import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = {'''v...
334
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase = { '''configuration_vision_encoder_decoder''': ['''VisionEnc...
334
1
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class lowercase__ ( lowerCAmelCase__, unittest.T...
340
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass...
325
0
import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class SCREAMING_SNAKE_CASE ( unittest.TestCase ): '''simple d...
319
def lowerCamelCase__ ( ): """simple docstring""" return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] snake_case = generate_large_matrix() snake_case = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3...
319
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCAmelCase_ ( ) -> tuple[list[int], int]: """simple docstring""" lowerCamelCase__: List[Any] =[randint(-1000 , 1000 ) for i in range...
10
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def lowerCAmelCase_ ( ) -> Optional[int]: """simple docstring""" lowerCamelCase__ , lowerCamelCase__: int =9, 14 # noqa: F841 lowerCamelCase__: Lis...
10
1
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids...
367
from __future__ import annotations def lowerCamelCase_ ( UpperCamelCase__ : list[float] , UpperCamelCase__ : list[float] ) -> float: """simple docstring""" __lowerCamelCase = sorted(numsa + numsa ) __lowerCamelCase , __low...
348
0
'''simple docstring''' def A__ ( UpperCAmelCase_ = 1_0_0_0 ): _UpperCamelCase : Dict = 3 _UpperCamelCase : Any = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: result -= a ...
83
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(lowercase )...
83
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : Optional[int] = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], }...
314
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case_( a__ ): def __init__( self : Dic...
314
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase : Dict = { """configuration_resnet""": ["""RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ResNetConfig""",...
20
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class a_ ( snake_case_ ): '''simple docstring''' def snake_case_( self ) -> Tuple: return [ {"col_1": 3, "col_2": "...
58
0
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": SCREAMING_SNAKE_CASE : Dict = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path...
252
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 ...
252
1
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...tes...
109
from __future__ import annotations from PIL import Image # Define glider example __lowerCAmelCase : Optional[int] = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0...
156
0
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 SCREAMING_SNAKE_CASE__ = 0B1_0_1_1_0_0_1_1_1_1_1_0_1_1_0_0_1_0_0_1_0_0_0_0_0_1_1_1_1_...
297
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: float ): '''simple docstring''' return 10 - x * x def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: float , __lowerCamelCase: float ): '''simple docstring''' if equation(__lowerCamelCase ...
297
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/...
74
"""simple docstring""" 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 snake_case__ ( snake_case_, snake_case_ ): @register_to_config def __init__( ...
261
0
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int = 1 , UpperCAmelCase_ : int = 10_00 ) -> int: '''simple docstring''' __snake_case : Any = 1 __snake_case : List[str] = 0 for divide_by_numb...
352
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _a : Dict= logging.get_logger(__name__) class UpperCamelCase ( lowercase ): def __init__(self : List[str] , *_A : Dict ...
95
0
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch ...
289
def snake_case__ ( SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' if len(SCREAMING_SNAKE_CASE_ ) != len(SCREAMING_SNAKE_CASE_ ): raise ValueError('String lengths must match!' ) lowercase__ : Union[str, Any] = ...
214
0
"""simple docstring""" import sys lowerCAmelCase__ : Any =( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557...
362
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __lowercase : """simple docstring""" _UpperCAmelCase = 42 ...
162
0
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class lowerCAmelCase_ ...
319
'''simple docstring''' from itertools import permutations def SCREAMING_SNAKE_CASE( __lowercase ) -> bool: if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False ...
319
1
"""simple docstring""" def _snake_case ( _snake_case : str , _snake_case : str ): lowerCAmelCase : Optional[int] = len(_snake_case ) lowerCAmelCase : List[Any] = [] for i in range(len(_snake_case ) - pat_len + 1 ): lowerCAme...
360
"""simple docstring""" def _snake_case ( _snake_case : int = 50000000 ): lowerCAmelCase : List[str] = set() lowerCAmelCase : List[Any] = int((limit - 24) ** (1 / 2) ) lowerCAmelCase : Optional[int] = set(range(3 , prime_square_limit + 1 , ...
314
0
'''simple docstring''' import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def snake_case_ ( __SCREAMING_SNAKE_CASE : str ): """simple docstring""" return np.dot(__snake_case , __snake_c...
93
"""simple docstring""" import os from math import logaa def _lowercase ( __snake_case = "base_exp.txt" ) -> int: __lowerCAmelCase : float = 0 __lowerCAmelCase : Any = 0 for i, line in enumerate(open(os.path.join(os.path.d...
269
0
def lowerCamelCase_ ( ): return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] __A =generate_large_matrix() __A =( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], [1, 0]], [[7, 7, 6]], [[7, 7, 6], [-1, -2, -3...
366
from __future__ import annotations import math def lowerCamelCase_ ( lowerCamelCase__ ): 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 are not primes ...
47
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE : Tuple = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch_availab...
314
def UpperCAmelCase_ ( _A ): '''simple docstring''' return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
314
1
'''simple docstring''' def lowerCAmelCase__ ( lowerCamelCase : dict ): _A : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack _A : set[int] = set() return any( node not in visit...
227
'''simple docstring''' import math from collections import defaultdict 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 KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput ...
227
1
"""simple docstring""" import os from pathlib import Path def lowercase__ ( ): from torch.utils.cpp_extension import load __UpperCAmelCase = Path(snake_case_ ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' __UpperCAmelCase = [ r...
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_fla...
366
"""simple docstring""" def A_ ( snake_case_ : int ): '''simple docstring''' if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
27
0
"""simple docstring""" import socket def snake_case__ ( ): """simple docstring""" lowerCamelCase__ : str =socket.socket(socket.AF_INET , socket.SOCK_STREAM ) lowerCamelCase__ : List[str] =socket.gethostname() lowerCamelCase__ : List[str] =12312 sock.connect((ho...
238
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowercase : Any = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): '''simple docstring''' def __init__...
238
1
import math def lowerCAmelCase__ ( _a : str , _a : Tuple ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(UpperCAmelCase_ ) else: if x == 0: # 0 raised to any number is 0 return 0 elif y...
352
import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils ...
36
0
from math import ceil, sqrt def UpperCAmelCase ( a_ = 1_0_0_0_0_0_0 ) -> Tuple: """simple docstring""" __A = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __A = max(ceil(sqrt(outer_width**2 - limit ) ...
15
def _A ( SCREAMING_SNAKE_CASE : Optional[Any] ): """simple docstring""" a__ : Optional[Any] =len(SCREAMING_SNAKE_CASE ) while cur > 1: # Find the maximum number in arr a__ : List[Any] =arr.index(max(arr[0:cur] ) ...
95
0
'''simple docstring''' import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging _a : Dict = logging.get_logger(__name__)...
353
'''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 : Dict = logging.get_logger(__name__) _a : Optional[i...
46
0
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO, ) a__ : T...
53
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class A__ : lowercase = 42 lowercase = None lowercase = None def...
162
0
"""simple docstring""" import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration A : Optional[int] = { "tiny.en": "https://openaipublic.azureed...
259
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase = "cpu" , _UpperCamelCase = None ): '''simple docstring''' __lowerCAmelCase = torch.load(_UpperCamelCase , map_location...
259
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy _A = logging.get_logger(__name__) ...
242
"""simple docstring""" 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 lowercase_ ( __UpperCAmelCase ) ->...
242
1
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets UpperCamelCase__ : int = '\\n@inproceedings{popovic-2015-chrf,\n title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation",\n author = ...
164
'''simple docstring''' def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def UpperCAmelCase ( ) -> None: """simple docstring""" assert or_g...
164
1
def A_ ( _UpperCAmelCase = 1_00_00_00 ): SCREAMING_SNAKE_CASE_: Dict = set(range(3 , _UpperCamelCase , 2 ) ) primes.add(2 ) for p in range(3 , _UpperCamelCase , 2 ): if p not in primes: continue primes.differenc...
13
'''simple docstring''' class A__ : def __init__( self : Union[str, Any] , _a : int ) -> None: '''simple docstring''' _SCREAMING_SNAKE_CASE =size _SCREAMING_SNAKE_CASE =[0] * size _SCREAMING_SNAKE_CASE =[0] * ...
47
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase = { """configuration_resnet""": ["""RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ResNetConfig""", """ResN...
370
def lowerCamelCase__ ( ) -> int: '''simple docstring''' return 1 def lowerCamelCase__ ( UpperCamelCase__ : int ) -> int: '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def lowerCamelCase__ ...
295
0
"""simple docstring""" import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) ...
96
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 lowerCAmelCase__( lowercase : Dict ) -> str: # picklable for multip...
326
0
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def _A ...
215
"""simple docstring""" import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testi...
215
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=lowerCAmelCase_ ): """simple docstring""" _lowerCAmelCase : Optional[int] = ["""torch""", """transformers""", """onnx"""] def __init__( self , *lowerCAmel...
150
'''simple docstring''' import requests from bsa import BeautifulSoup def lowerCamelCase (_SCREAMING_SNAKE_CASE : str = "https://www.worldometers.info/coronavirus" ): __a : List[Any] = BeautifulSoup(requests.get(_SCREAMING_SNAKE_CASE ).text , 'html.parser' ...
27
0
import os def a__ ( ): """simple docstring""" __SCREAMING_SNAKE_CASE = os.path.join(os.path.dirname(a__ ) , """num.txt""" ) with open(a__ ) as file_hand: return str(sum(int(a__ ) for line in file_hand ) )[:10] if __name__ ==...
358
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( a ): """simple docstring""" lowerCAmelCase__ = (DDPMScheduler,) def UpperCAmelCase__ ( self : Union[str, Any] , **__SCR...
331
0
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.ut...
68
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) from transfo...
36
0
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( B...
196
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_image_inputs if is_torch_availab...
196
1
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__(self : int , a__ : int , a__ : int , a__ : float = 0 ): """simple docstring""" __sna...
24
"""simple docstring""" from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_...
46
0
import math def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = 0 , _UpperCAmelCase = 0 ): __a = end or len(a__ ) for i in range(a__ , a__ ): __a = i __a = array[i] while temp_index != start and temp_in...
369
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 __snake_case :Dict = logging.get_logger(__name__...
131
0
from __future__ import annotations import pandas as pd def _A ( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase :int = [0] * no_of_processes UpperCamelCase :Optional[Any] = ...
259
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 _A ( SCREAMING_SNAK...
259
1
def UpperCAmelCase ( a_ , a_ ) -> str: """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...
124
import copy import re class UpperCAmelCase : '''simple docstring''' snake_case_ = "hp" snake_case_ = {} snake_case_ = None @classmethod def UpperCamelCase_ ( cls : Dict ,A : Dict ,A : Any ): __A = prefix __A ...
124
1
'''simple docstring''' from __future__ import annotations __A = list[list[int]] # assigning initial values to the grid __A = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], ...
164
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
164
1
# 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 _UpperCAmelCase ( Tenso...
63
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, 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_p...
63
1