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""" from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def A_ ( ): '''simple docstring''' snake_case_, snake_case_ :Tuple = 9, 14 # noqa: F841 snake_case_ :Optional[Any] = [ [0...
66
"""simple docstring""" import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin,...
66
1
"""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 ...
367
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .ben...
286
0
from maths.prime_factors import prime_factors def A ( _lowerCamelCase ): '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): _lowerCAmelCase : int = F"Input value of [number={number}] must be an integer" ...
36
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected" , [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10, "max_num_jobs": 1}, [range...
22
0
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hub_u...
365
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowercase__ =10 def __UpperCamelCase ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ...
90
0
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImage...
174
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase : Dict = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """Mvp...
174
1
"""simple docstring""" from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __SCREAMING_SNAKE_CASE ( snake_case_): _SCR...
356
import colorsys from PIL import Image # type: ignore def _UpperCamelCase ( UpperCamelCase_ : float , UpperCamelCase_ : float , UpperCamelCase_ : int ) -> float: """simple docstring""" lowerCAmelCase__ = x lowerCAmelCase__...
122
0
"""simple docstring""" import csv import tweepy # Twitter API credentials _A = "" _A = "" _A = "" _A = "" def a__ ( lowerCAmelCase ) -> None: # authorize twitter, initialize tweepy UpperCAmelCase__ : List[str] = tweepy.OAuthHandler(lowerCA...
171
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils impo...
336
0
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, PNDMScheduler, ...
75
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
75
1
'''simple docstring''' 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_...
341
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], ...
341
1
"""simple docstring""" __UpperCamelCase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __UpperCamelCase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def lowercase (SCREAMING_SNAKE_CASE_ : dict[int, list[int]] , SCREAMING_SNAKE_CASE_ : int , ...
38
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from a...
38
1
'''simple docstring''' import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase (lowercase_ , unittest.TestCase ): '''simple docs...
2
'''simple docstring''' import unittest from transformers import DonutProcessor lowerCamelCase : Tuple = 'naver-clova-ix/donut-base' class __lowerCAmelCase (unittest.TestCase ): '''simple docstring''' def UpperCamelCase__ (self : int ): '...
2
1
from __future__ import annotations from scipy.special import comb # type: ignore class _lowercase : def __init__( self : List[Any] , snake_case : Tuple ) -> Optional[Any]: """simple docstring""" UpperCamelCase_ : Union[str, Any] = list_of_p...
363
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from transfo...
50
0
def __magic_name__ ( __lowerCAmelCase : str ) -> bool: __lowerCamelCase = [int(__lowerCAmelCase ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(__lowerCAmelCase ) == 4 and all(0 <= int(__lowerCAmelCase ) <= 254 for octet in octets ) ...
270
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils import r...
270
1
from __future__ import annotations import collections import pprint from pathlib import Path def _snake_case( SCREAMING_SNAKE_CASE__ ) -> str: return "".join(sorted(SCREAMING_SNAKE_CASE__ ) ) def _snake_case( SCREAMING_SNAKE_CASE__ ) -> list[str]: return w...
285
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 lowercase : List[Any] = logging.get_logger(__name__) lowercase : List[Any] = { ...
285
1
'''simple docstring''' def __magic_name__( lowerCamelCase, lowerCamelCase): return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __magic_name__( lowerCamelCase, lowerCamelCase=0): return sorted(A__, key=lambda lowerCamelCase: x[column]) def __magic_n...
174
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin ...
268
0
"""simple docstring""" import requests SCREAMING_SNAKE_CASE__ = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def lowerCAmelCase__ ( _UpperCamelCase : str ) -> None: """simple docstring""" snake_case = req...
149
"""simple docstring""" 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...
149
1
import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from fla...
5
UpperCAmelCase__ = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''': '''-.''',...
5
1
"""simple docstring""" import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) _UpperCamelCase = l...
234
"""simple docstring""" import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( ...
234
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class lowerCAmelCase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self...
37
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch ...
37
1
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_...
323
from __future__ import annotations from typing import Any class __A : def __init__( self : Optional[Any] , UpperCAmelCase_ : int ): lowerCAmelCase : Tuple = num_of_nodes lowerCAmelCase : list[list[int]] = [] ...
323
1
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) a : Dict = { 'sample_size': 32, 'in_channels': 3, 'out_channels': 3, 'layers_per_block': 2, 'num_class_emb...
56
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : str = logging.get_logger(__name__) a : str = { 'google/bigbird-roberta-base': ...
56
1
"""simple docstring""" import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingC...
351
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) ...
258
0
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table,...
95
from __future__ import annotations import numpy as np def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ , snake_case_ = np.shape(UpperCamelCase__ ) if rows != columns: snake_case_ = ( ...
285
0
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCAmelCase__ ( ...
324
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() cl...
324
1
"""simple docstring""" from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( lowercase_ ): _a = 'SpeechT5FeatureExtractor' _a = 'SpeechT5Tokenizer' def __init__( self : Dict , lowerCAmelCase : Union[str, Any] , lowerCAmelCas...
155
"""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....
224
0
'''simple docstring''' import logging import os from .state import PartialState class _snake_case ( logging.LoggerAdapter ): @staticmethod def lowerCAmelCase__ ( a__ ) -> Optional[Any]: '''simple docstring''' snake_case_ = Par...
92
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class _snake_case : def __init__( self , a__ ) -> Union[str, Any]: '''simple docstring''' snake_case_ = list_of_points # Degr...
92
1
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils imp...
23
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: if n == 1 or not isinstance(__UpperCAmelCase , __UpperCAmelCase ): return 0 elif n == 2: return 1 else: lowercase__: List[Any] = [0, 1] for i in range(2 , n + 1 ): ...
177
0
'''simple docstring''' import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib lowercase__ : ...
367
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def a__ ( lowercase : Tuple ) -> Dict: """simple docstring""" _U...
287
0
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer snake_case__ : Optional[Any] = logging.getLogger(__name__) def _snake_case ( ): lowerCAmelCase : Tuple = argparse.ArgumentParser( ...
60
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase ) -> list: if len(UpperCAmelCase ) <= 1: return [tuple(UpperCAmelCase )] snake_case_ = [] def generate(UpperCAmelCase , UpperCAmelCase ): snake_case_ = ...
69
0
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _A ( A__ , A__ , A__ = 1 / sqrt(2 ) ): """simple docstring""" __lowercase = tau * frequency / samplerate __lowercase = sin(A__ ) __low...
52
'''simple docstring''' # Function to print upper half of diamond (pyramid) def _A ( A__ ): """simple docstring""" for i in range(0 , A__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end='''''' ) for _ in range(0 , i + 1...
52
1
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( i...
173
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json""", # See all V...
173
1
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_configuration_common i...
252
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
252
1
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A_ :Tuple = logging.get_logger(__name__) class __A ( a ): """simple docstring""" ...
71
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :Any = logging.get_logger(__name__) A_ :int = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT...
71
1
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 ImageProcessingSavingTestMixin, prepare_image_inputs if i...
352
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 def __lowercase ( _Up...
173
0
def A_ ( A__ , A__ ) -> None: a__ : str = len(A__ ) print('The following activities are selected:' ) # The first activity is always selected a__ : Dict = 0 print(A__ , end=',' ) # Consider rest of the activities for j in...
99
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowercase : Any = logging.get_logger(__name__) # pylint: disable=invalid-name class A__ ( __UpperCAmel...
99
1
"""simple docstring""" import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_dif...
353
"""simple docstring""" 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 ( Channe...
324
0
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def snake_case__ ( _A: Optional[Any] , _A: List[Any] , _A: Union[str, Any] , _A: str ) -> Optional[Any]: '''simple docstring''' lowerCAmelCase = ...
272
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ......
272
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ ( UpperCAmelCase_ ): A__ : Optional[Any] = (DDIMParallelScheduler,) A__ : List[Any] = (("""eta""", 0.0), ("""num_inference_steps""", 50)) def lowerCame...
367
import math def lowerCamelCase__ ( a__ : float , a__ : float ) -> float: if ( not isinstance(a__ , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("""power_factor must be a valid float...
261
0
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB...
187
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data imp...
187
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModel...
342
import flax.linen as nn import jax import jax.numpy as jnp class _snake_case ( nn.Module ): lowerCamelCase__: int lowerCamelCase__: jnp.dtype = jnp.floataa def _lowerCamelCase ( self: Tuple ) -> Union[str, Any]: __UpperCAmelCase...
342
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = {} class lowerCamelCase_ ( SCREAMING_SNAKE_CASE_ ): """simple ...
208
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffuse...
208
1
'''simple docstring''' import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, ...
334
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDep...
334
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 AbstractDatasetInputStream if TYPE_CHECKING: ...
75
import functools def lowerCamelCase__ ( __lowerCAmelCase : str , __lowerCAmelCase : str ): """simple docstring""" lowerCAmelCase_ = len(__lowerCAmelCase ) lowerCAmelCase_ = len(__lowerCAmelCase ) @functools.cache def min_distance(__lowerCAmelCase : ...
231
0
"""simple docstring""" from collections import defaultdict from math import gcd def UpperCAmelCase__ (lowerCAmelCase_ = 150_0000 ): '''simple docstring''' __SCREAMING_SNAKE_CASE = defaultdict(lowerCAmelCase_ ) __SCREAMING_SNAKE_CASE = 2...
361
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' return " ".join( "".join(word[::-1] ) if len(lowerCAmelCase_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.te...
195
0
'''simple docstring''' def snake_case_ ( _lowerCAmelCase : int ) -> List[Any]: if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True UpperCAmelCase : Any = 4 Up...
23
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={ """camembert-base""": """https://huggingface.co/camembert...
287
0
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _UpperCamelCase = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _UpperCamelCase = typing.Union[np.floataa, int, float] ...
370
'''simple docstring''' 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, ) _UpperCamelCase = { '...
16
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, slow ...
101
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' lowercase = ('''dense.weight''', '''attention.self.qu...
101
1
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _lowerCamelCase : int...
356
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: if no...
231
0
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnP...
261
"""simple docstring""" from collections import Counter from timeit import timeit def _lowerCamelCase( a = "" , ): return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def _lowerCamelCase( a = "" ): if len(a ...
261
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
295
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, ) def lowerCamelCase__ ( UpperCamelCa...
295
1
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _A = logging.get_logger(__name__) class UpperCAmelCase__ ( A_ ): """simple docstring""" def __init__( self , *A_ , **A_ ) -> Non...
62
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQVAEConfig', ], ...
62
1
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( cente...
352
import enum import shutil import sys lowercase , lowercase : List[Any] = shutil.get_terminal_size() lowercase : Union[str, Any] = {"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""} class A__ ( enum.Enum ): """simple ...
225
0
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin _snake_case ...
26
from math import asin, atan, cos, radians, sin, sqrt, tan _snake_case = 6_3_7_8_1_3_7.0 _snake_case = 6_3_5_6_7_5_2.3_1_4_2_4_5 _snake_case = 6378137 def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_ ): _A : Any ...
26
1
"""simple docstring""" import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @re...
360
"""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 FlaxStableDiffusionControlNetPipeline # noq...
233
0
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _SCREAMING_SNAKE_CASE : List[Any] = "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company...
85
'''simple docstring''' 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 ( A ): ...
166
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _a : Union[str, Any] = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP'...
126
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE ( _lowerCamelCase : list ) -> float: if not nums: raise ValueError("""List is empty""" ) return sum(_lowerCamelCase ) / len(_lowerCamelCase ) if __name__ == "__main__": impo...
126
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_te...
125
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartFor...
125
1
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class A__ ( A__ ): def __init__( self : str , _a : Dict , _a : int , _a : str ) -> Option...
114
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
114
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : Optional[Any] ={ """config...
128
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, ...
128
1
'''simple docstring''' import unittest import numpy as np from transformers import BertConfig, 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_fla...
249
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Tuple = { "configuration_convnext": ["CONVNEXT_PRE...
249
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
125
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartFor...
125
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class snake_case ( unittest.TestCa...
303
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { 'configuration_lilt': ['LILT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LiltConfig'], } try: if not is_torch_available(): raise Option...
303
1
def lowerCamelCase_ ( _a : str ): '''simple docstring''' stooge(_lowercase , 0 , len(_lowercase ) - 1 ) return arr def lowerCamelCase_ ( _a : Optional[int] , _a : int , _a : List[str] ): '''simple docstring''' i...
345
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1_337 , num_examples=42 , dataset_name='''my_dataset'''...
182
0
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets a__: Tuple = datasets.logging.get_logger(__name__) a__: Optional[int] = '\\n@InProceedings{moosavi2019minimum,\n...
39
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__: List[Any] = logging.get_logger(__name__) a__: Optional[Any] = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/microsoft/unispeec...
39
1
def _UpperCAmelCase ( a__): '''simple docstring''' a_ : str = [0 for i in range(len(a__))] # initialize interval's left pointer and right pointer a_ , a_ : Optional[Any] = 0, 0 for i in range(1 , len(a__)): # case when current index is inside...
248
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 __snake_case : Dict = logging.get_logger(__name__) __snake_case : Any ...
248
1
import string import numpy def __lowerCamelCase ( __magic_name__ : List[str] , __magic_name__ : Optional[Any] ): return b if a == 0 else greatest_common_divisor(b % a , A_ ) class lowerCamelCase__ : _lowerCAmelCase = string.ascii_uppercase + string.digits ...
357
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class lowerCamelCase__ ( _a ): @require_torch def _lowerCamelCase ( self : Union[str, Any] ): ...
42
0
"""simple docstring""" import math from datetime import datetime, timedelta def lowercase__ ( snake_case_ :str ): __UpperCAmelCase = year % 19 __UpperCAmelCase = year % 4 __UpperCAmelCase = year % 7 __UpperCAmelCase = math.floor(year...
332
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def _UpperCamelCase ( snake_case__, snake_case__, snake_case__ ) -> tuple[int | None, int | None, float]: if not arr: ...
157
0
'''simple docstring''' 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 ( __a ...
98
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils...
98
1
"""simple docstring""" from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_visio...
100
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase__ : int = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lowercase__ : Option...
338
0
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers....
351
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _UpperCamelCase = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn"...
234
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = {'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class lowerCamelCase__ ( _snake_case): SCREAMING_...
5
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..model...
29
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ ...
183
'''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 SCREAMING_SNAKE_CASE__ = ...
183
1
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available if is_vision...
262
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMi...
262
1
'''simple docstring''' import unittest from transformers import DonutProcessor A : str = '''naver-clova-ix/donut-base''' class __lowerCamelCase ( unittest.TestCase ): """simple docstring""" def A ( self : Union[str, Any]): _A : Any ...
227
'''simple docstring''' class __lowerCamelCase : # Public class to implement a graph """simple docstring""" def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : ...
227
1
"""simple docstring""" from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_avail...
320
"""simple docstring""" from ..utils import DummyObject, requires_backends class __lowerCamelCase ( metaclass=a__ ): '''simple docstring''' A_ : Optional[Any] = ['flax'] def __init__( self , *__UpperCAmelCase , **__UpperCAmelCase ) -> int: ...
320
1
from collections.abc import Generator from math import sin def __lowerCamelCase ( __a :bytes ) -> bytes: """simple docstring""" if len(__a ) != 3_2: raise ValueError("""Input must be of length 32""" ) A__ = b"""""" for ...
276
import argparse import math import traceback import dateutil.parser as date_parser import requests def __lowerCamelCase ( __a :str ) -> Optional[int]: """simple docstring""" A__ = {} A__ = job["""started_at"""] A...
276
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor UpperCAmelCase : Any = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): def __init__( self : List[Any]...
136
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase = 1_00_00_00 ) -> int: '''simple docstring''' lowercase_ = 1 lowercase_ = 1 lowercase_ = {1: 1} for inputa in range(2 , __lowerCAmelCase ): low...
136
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : List[str] = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torc...
355
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE ( _a ): """simple docstring""" _SCREAMING_SNAKE_CASE = (UnCLIPScheduler,) def A ( ...
249
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 UpperCAmelCase_ ( unit...
4
'''simple docstring''' import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def a_ ( lowerCamelCase : Dict ): lowerCAmelCase = {} lowerCAmel...
4
1
UpperCAmelCase =range(2, 20 + 1) UpperCAmelCase =[10**k for k in range(ks[-1] + 1)] UpperCAmelCase ={} def _A ( _a : int , _a : Tuple , _a : Tuple , _a : Optional[int] ): """simple docstring""" A ...
355
"""simple docstring""" from typing import Dict, Iterable, 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, ...
77
0
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, r...
33
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs i...
266
0
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ ( lowercase_ ): """simple docstring""" ...
289
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowercase__ : Optional[int] = { """configuration_...
289
1
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__UpperCAmelCase ) class snake_case ( __UpperCAmelCase ): """simple docstring""" snake_case__ ...
98
'''simple docstring''' import requests __a: str = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def __UpperCamelCase ( UpperCAmelCase ): # fetching a list of articles in json format lowercase__ : Optional[Any] = requests.get(_NEWS_API + bbc_news_api_ke...
198
0
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn ...
155
"""simple docstring""" 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, ) lowercase__ : List[Any] = { '''confi...
155
1
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers.uti...
43
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _SCREAMING_SNAKE_CASE ( *SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = None , SCREAMING_SNAKE_CASE=True , SCREAMING_SNAKE_CASE=2 ): from .. import __version__ A_ : Union[str, A...
186
0
"""simple docstring""" from math import sqrt def lowercase__ ( lowercase_ ) -> int: """simple docstring""" _UpperCamelCase : int = 0 for i in range(1 ,int(sqrt(lowercase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowercase_ ): ...
310
"""simple docstring""" from typing import Any def lowercase__ ( lowercase_ ) -> list[Any]: """simple docstring""" if not input_list: return [] _UpperCamelCase : Dict = [input_list.count(lowercase_ ) for value in input_list] _UpperCamelCa...
310
1
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef a__ : str = ( 'This metric will be removed from the ...
80
'''simple docstring''' a__ : Union[str, Any] = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _UpperCamelCase ( __A ) -> int: '''simple docstring''' UpperCamelCase__ = 0 while number: # In...
80
1
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> bool: lowerCamelCase__ : List[Any] = str(UpperCamelCase ) return n == n[::-1] def SCREAMING_SNAKE_CASE_ (UpperCamelCase = 10000...
129
'''simple docstring''' from __future__ import annotations from typing import Any class _lowercase ( _lowercase ): pass class _lowercase : def __init__( self: Optional[int] , UpperCamelCase__: Any ): l...
129
1
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter A_ ...
71
"""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 TOKENIZER_CONFIG_FILE from tra...
243
0
"""simple docstring""" import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() UpperCAmelCase =logging.get_logger(__name__) def _A ( _a ...
357
"""simple docstring""" 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 ....
77
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json", "tiiuae/falcon-7b": "https://huggingface.co...
35
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput fr...
307
0
'''simple docstring''' from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
83
'''simple docstring''' import requests lowercase__ = "" # <-- Put your OpenWeatherMap appid here! lowercase__ = "https://api.openweathermap.org/data/2.5/" def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = "Chicago" , SCREAMING_SNAKE_CASE__ = APPID ) -> dict: '''sim...
83
1
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance lowerCamelCase = 6_3_7_8_1_3_7.0 lowerCamelCase = 6_3_5_6_7_5_2.3_1_4_2_4_5 lowerCamelCase = 637_8137 def _A ( _lowerCAmelCase , _low...
166
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
166
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator,...
295
def lowerCamelCase__ ( UpperCamelCase__ : Tuple , UpperCamelCase__ : Optional[int] ) -> Tuple: '''simple docstring''' _snake_case = [0 for i in range(r + 1 )] # nc0 = 1 _snake_case = 1 for i in range(1 , ...
295
1
'''simple docstring''' from math import sqrt def lowerCAmelCase_ ( snake_case_ : int ) -> int: '''simple docstring''' UpperCAmelCase_ = 0 for i in range(1 , int(sqrt(snake_case_ ) + 1 ) ): if n % i == 0 and i != sqrt(snake_case_ ...
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Dict = logging.get_logger(__name__) lowerCamelCase__ : Any = { 'facebook/s2t-small-librispeech-asr': ( 'https://huggingface.co/facebook/s2t-small-librispeec...
210
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def UpperCAmelCase_ ( __UpperCAmelCase : Optional[int] ) -> int: if not is_accelerate_available(): return method SCREAMING_SNAKE_...
210
1
import copy import re class A__ : _UpperCAmelCase :Union[str, Any] = '''hp''' _UpperCAmelCase :str = {} _UpperCAmelCase :List[Any] = None @classmethod def __UpperCamelCase( cls , A_ , A_ ): '''sim...
52
"""simple docstring""" 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.transfor...
315
0
"""simple docstring""" print((lambda quine: quine % quine)('print((lambda quine: quine %% quine)(%r))'))
369
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": _lowercase : int = pd.read_csv('sample_data.csv', hea...
86
0
import argparse import os import re UpperCamelCase = '''src/transformers''' # Pattern that looks at the indentation in a line. UpperCamelCase = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase = re.compile(R'''^\s*"...
87
'''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_tokenizers...
324
0
"""simple docstring""" import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate imp...
369
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepi...
241
0