code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowercase (SCREAMING_SNAKE_CASE_ : str ) -> Union[str, Any]: SCREAMING_SNAKE_CASE = [ """encoder...
247
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Union[str, Any] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class Upp...
635
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase : Optional[int] = logging.get_logger(__name__) UpperCAmelCase : Optional[Any] ...
716
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from...
47
0
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
287
import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing import PolynomialFeature...
287
1
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_A ): """simple docstring""" A = ['''note_seq'''] def __init__( self , *_lowerCAmelCase , **_lowerCAmelCase ): '''simple docstring''' requires_backe...
111
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 tokenizers _...
111
1
import os import numpy import onnx def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: Dict , UpperCamelCase__: str ): SCREAMING_SNAKE_CASE__ = a.name SCREAMING_SNAKE_CASE__ = b.name SCREAMING_SNAKE_CASE__ = """""" SCREAMING_SNAKE_CASE__ =...
6
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuratio...
85
0
'''simple docstring''' lowerCAmelCase__ : List[str] = { """Pillow""": """Pillow<10.0.0""", """accelerate""": """accelerate>=0.20.3""", """av""": """av==9.2.0""", """beautifulsoup4""": """beautifulsoup4""", """black""": """black~=23.1""", """codecarbon""": """codecarb...
502
'''simple docstring''' import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import comput...
502
1
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=...
188
'''simple docstring''' import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPho...
286
0
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow...
703
import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) UpperCamelCase = logging.getLogger() def A ( lowercase__ : ...
383
0
"""simple docstring""" import os import sys import unittest UpperCamelCase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get...
227
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ...
458
0
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int = 100_0000 ): '''simple docstring''' lowercase_ = limit + 1 lowercase_ = [0] * limit for first_term in range(1 , __lowerCamelCase ): for n in range(__lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): ...
601
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from...
601
1
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is...
34
import math def _A ( SCREAMING_SNAKE_CASE : int ): """simple docstring""" 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 ...
563
0
"""simple docstring""" from __future__ import annotations import math def lowercase ( __snake_case : int , __snake_case : int , __snake_case : bool , __snake_case : list[int] , __snake_case : float ): if d...
141
"""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 _UpperCAm...
141
1
"""simple docstring""" snake_case = '''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def snake_case ( lowerCAmelCase_ ) -> bytes: # Make sure the supplied data is a bytes-like object if not isinstance(lowerCAmelCase_ , lowerCAmelCase...
103
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): @staticmethod @abstractmethod def __UpperCAmelCase ( __lowerCamelCase : ArgumentParser ): "...
103
1
'''simple docstring''' import math from datetime import datetime, timedelta def lowerCAmelCase__ ( UpperCAmelCase ): """simple docstring""" snake_case__ : List[str] = year % 19 snake_case__ : Optional[Any] = ye...
172
'''simple docstring''' from __future__ import annotations def lowerCAmelCase__ ( UpperCAmelCase , UpperCAmelCase ): """simple docstring""" if len(UpperCAmelCase ) <= 1 or n <= 1: return insert_next(UpperCAmelCase ...
172
1
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEncoder, ...
278
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = False ) -> list[float]: '''simple doc...
530
0
'''simple docstring''' from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ) -> None: """simple docstring"...
323
'''simple docstring''' from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ) -> None: """simple docstring"...
323
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
376
import numpy as np def lowerCamelCase__ ( _A ): '''simple docstring''' return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
376
1
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, temp...
720
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : List[str] = len(_UpperCamelCase ) __lowerCAmelCase : Tuple = [[0] * n for i in range(_UpperCamelCase )] for i in range(_UpperCamelCase ): __lower...
549
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __a: int = ''' Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenager...
108
'''simple docstring''' import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCamelCase ( a , a ) -> Tuple: ...
432
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __A : Optional[int] = logging.get_logger(__name__) __A : List[Any] = r""" Args: input_...
703
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np __A : Dict = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 __A : Tuple = typing.Union[np.floataa, int, float] # noqa: UP007 def lowerCamelC...
450
0
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 impor...
61
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transfo...
61
1
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) # TODO Update this _SCREAMING_SNAKE_CASE : Optional[int] = { '...
55
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXT...
55
1
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel A_ = logging.getLog...
29
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation ...
311
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, ...
436
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
436
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : List[Any] = logging.get_logger(__name__) _snake_case : int = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json", } ...
441
"""simple docstring""" from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class __a : pass
552
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, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffuse...
84
import re def a_ ( __magic_name__ ) -> bool: """simple docstring""" snake_case : List[str] = re.compile( R'''^(?:0|94|\+94|0{2}94)''' R'''7(0|1|2|4|5|6|7|8)''' R'''(-| |)''' R'''\d{7}$''' ) return bool(re.search(...
84
1
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_...
520
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'google/bit-50': 'https://huggi...
520
1
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, Stabl...
717
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : str ,lowerCAmelCase_ : str ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] =get_failure_array(lowerCAmelCase_ ) ...
153
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class lowerCAmelCase : '''simple docstring''' def __init__( self : List[str] , __a : Collection[float] | None = None ) -> None: ...
149
from __future__ import annotations class lowerCAmelCase : '''simple docstring''' def __init__( self : str , __a : Dict=None ) -> int: """simple docstring""" __lowercase : int = data __lowercase : Optional[int...
149
1
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node a__ : Optional[int] = 4 a__ : Union[str, Any] = 3 class ...
721
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_ut...
223
0
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switch_...
278
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() A : D...
219
0
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class lowerCAmelCase : def __init__( self :Optional[int] ): '''simple docstring''' lowercase__ = "" lowercase__ = "" lowercase__...
611
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from transforme...
611
1
"""simple docstring""" import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformer...
139
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def lowerCamelCase ( ) -> Optional[int]: '''simple docstring''' __UpperCAmelCase : Any = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args>]"...
139
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class UpperCamelCase (lowercase__ ): def __init__( self :List[Any] , *__magic_name__...
704
"""simple docstring""" # 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/LI...
348
0
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils im...
576
def UpperCAmelCase__( __UpperCAmelCase : int ): if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True __snake_case : str = 4 __snake_case : List[str] = (1 << p) - 1 for _ in range(p - 2 ): ...
576
1
'''simple docstring''' import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Tok...
709
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if i...
537
0
'''simple docstring''' import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_d...
71
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowerCAmelCase_ = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """))) pr...
411
0
'''simple docstring''' def __magic_name__( _A , _A ): '''simple docstring''' UpperCamelCase__ = len(_A ) UpperCamelCase__ = len(_A ) UpperCamelCase__ = ( first_str_length if first_str_length > second_str_length else second_st...
265
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase_ : str = logging.get_logger(__name__) lowerCamelCase_ : Optional[int] = { '''SenseTime/deformable-detr''': '''ht...
265
1
'''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 #...
41
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _UpperCamelCase ( ): """simple docstring""" __magic_name__ : Optional[int] = 9 __magic_name__ : Tuple = [ ...
436
0
import os 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_pegasus import PegasusTokenizer else: _lowerCAmelCase : ...
604
def UpperCAmelCase_ ( snake_case__ = 200 ) -> int: """simple docstring""" lowerCAmelCase__ = [1, 2, 5, 10, 20, 50, 100, 200] lowerCAmelCase__ = [0] * (pence + 1) lowerCAmelCase__ = 1 # base case: 1 way to make 0 pence for coin in coins: ...
604
1
'''simple docstring''' from __future__ import annotations def _snake_case ( A , A ) -> float: lowerCAmelCase__ = sorted(numsa + numsa ) lowerCAmelCase__ , lowerCAmelCase__ = divmod(len(A ) , 2 ) if mod == 1: ...
90
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface impor...
402
0
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class _lowerCAmelCase( _a , unittes...
704
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets _UpperCamelCase : Optional[int] = datasets.logging.get_logger(__name__) _UpperCamelCase : Dict = """\ @inproceedings{bleurt, title={BLEURT: Learning Robust ...
341
0
import math def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> float: '''simple docstring''' if ( not isinstance(SCREAMING_SNAKE_CASE , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError(...
303
def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Union[str, Any]: '''simple docstring''' __UpperCAmelCase = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def __a ( SC...
303
1
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from tran...
193
import math def lowerCamelCase__ ( _a , _a): if ( not isinstance(_a , (int, float)) or power_factor < -1 or power_factor > 1 ): raise ValueError("power_factor must be a valid float value between -1 and 1.") return apparent_power * power_factor def lowerCamelCase__ ( _a ...
193
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
95
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def _lowerCamelCase( a , a = "cpu" , a = None ): __a = torch.load(a , map_location=a ) for k, v in tqdm(state_dict.items() ): if not isinstance(a , tor...
528
0
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ...
397
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def lowercase__ ( ): with offline(OfflineSimulationMode.CONNECTION_T...
397
1
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowerCamelCase_ ( _UpperCAmelCase ): __lowercase : ...
147
"""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 # ...
698
0
from __future__ import annotations from typing import Any def lowerCamelCase_ ( lowerCAmelCase: list[Any] )-> None: create_state_space_tree(lowerCAmelCase , [] , 0 ) def lowerCamelCase_ ( lowerCAmelCase: list[Any] , lowerCAmelCase: list[Any] , lo...
669
def lowerCamelCase_ ( lowerCAmelCase: int )-> list: _snake_case : List[Any] = int(lowerCAmelCase ) if n_element < 1: _snake_case : int = ValueError('a should be a positive number' ) raise my_error _snake_case : Union[str, Any] ...
669
1
def lowerCAmelCase_ ( __a , __a ) -> list[int]: """simple docstring""" lowerCamelCase__: Optional[int] =int(__a ) # Initialize Result lowerCamelCase__: Any =[] # Traverse through all denomination for denomination in reversed(__a ): ...
59
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureEx...
431
0
'''simple docstring''' def lowerCAmelCase (__A = 1_000): """simple docstring""" _a = 2**power _a = 0 while n: _a , _a = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input())...
719
'''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...
352
0
import math class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : int , lowerCAmelCase__ : Tuple=0 ) -> List[Any]: # a graph with Node 0,1,...,N-1 snake_case__ = n snake_case__ = [ ...
214
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[int] = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/...
156
0
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierO...
525
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_availa...
525
1
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def lowerCamelCase_ ( UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ = 1 / sqrt(2 ) ): """simple docstring""" a_ = tau * frequency / samp...
483
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase_ ( __lowerCAmelCas...
7
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Tuple = { """google/pix2struct-textcaps-base""": ( ...
705
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __lowerCAmelCase ( _UpperCamelCase ): @require_torch def _snake_case ( self ) -> str: """simple ...
629
0
from __future__ import annotations A_ : Union[str, Any] = 'Muhammad Umer Farooq' A_ : Tuple = 'MIT' A_ : int = '1.0.0' A_ : Optional[int] = 'Muhammad Umer Farooq' A_ : Dict = ...
57
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''', } class lowerCA...
247
0
def __UpperCamelCase ( a, a) ->Optional[int]: if b == 0: return 1 if (b % 2) == 0: return actual_power(a, int(b / 2)) * actual_power(a, int(b / 2)) else: return a * actual_power(a, int(b / 2)) * actual_power(a, int(b / 2)) def __U...
360
from __future__ import annotations class SCREAMING_SNAKE_CASE_ : """simple docstring""" def __init__( self , _lowerCAmelCase , _lowerCAmelCase ): lowerCamelCase__ , lowerCamelCase__ = text, pattern lowerCamelCase__ , lowerCamelCase__ = len(_l...
360
1
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _SCREAMING_SNAKE_CASE = '.' # Internal TensorFlow ops tha...
401
'''simple docstring''' import math def a__ ( a__ ): """simple docstring""" return math.sqrt(a__ ) * math.sqrt(a__ ) == num def a__ ( a__ ): """simple docstring""" __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = n while left <= ...
627
0
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class lowerCamelCase__ ( yaml.SafeLoader ): """simple docstring""" def lowerCamelCase__ ( self : Optional[int] , UpperCamelCase ...
707
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, loggin...
299
0
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def snake_case_ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ = Non...
199
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def A__ ( __A : Any , __A : str , __A : str , __A : Path , __A : str = None , __A :...
184
0
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() __A =logging.get_logger(__name__) __A ={ '''post_extract_proj''': '''feature_projection.projection''', '''encoder.pos_co...
313
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowerCamelCase_ ( lowerCamelCase__ ): if "cls_token" in name: lowerCamelCase_ = name.replace("cls_token" , "vit.em...
313
1
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase_ : Tuple = 3 def A__ ( snake_case_ : int ): print('''Generating primitive root of p''' ) while True: SCREAMING_SNAKE_CASE__: List[Any]= random.randrange(3 ...
64
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ : Optional[int] = logging.get_logger(__name__) def A__ ( snake_case_ : List[Any] ): SCREAMING_SNAKE_...
64
1
'''simple docstring''' import gc import threading import time import psutil import torch class lowercase_ : """simple docstring""" def __init__( self : List[Any] ): __lowercase = psutil.Process() __lowercase = False def SCREAMI...
720
'''simple docstring''' def _A ( A__ ): """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) __lowercase = sum(A__ ) / len(A__ ) # Calculate the average return sum(abs(x - average ) for x in nums ) / ...
624
0
"""simple docstring""" import math import qiskit def _snake_case ( _snake_case : int = 1 , _snake_case : int = 1 , _snake_case : int = 1 ) -> qiskit.result.counts.Counts: '''simple docstring''' if ( isinstance(_snake_case ,...
7
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case_ (lowerCamelCase_ ): UpperCAmelCase__ : List[str] = ['''image_processor''', '''tokenizer'''] UpperCAmelCase__ : Dict = '''CL...
335
0
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ...
476
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 lowerCAmelCase ( unittest.TestCase ): def a__ ( self ): ...
476
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_mod...
94
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dimensio...
36
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase : Optional[Any] = { "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json", } class ...
718
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 TokenizerTester...
177
0
'''simple docstring''' import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import Base...
368
'''simple docstring''' a__ : Optional[Any] = '''Alexander Joslin''' import operator as op from .stack import Stack def __lowerCamelCase ( UpperCAmelCase_ ) ->int: snake_case__ = {'*': op.mul, '/': op.truediv, '+': op.add, '-': op.sub} ...
368
1
'''simple docstring''' import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester ...
680
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
680
1
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __A : int = False class __lowerCAmelCase ( ...
656
'''simple docstring''' import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table i...
44
0
"""simple docstring""" from random import shuffle import tensorflow as tf from numpy import array def A__ ( A__ , A__ ) -> Optional[int]: '''simple docstring''' _UpperCAmelCase = int(A__ ) assert noofclusters < len(A__ ) # Find out the dimensionality _U...
579
"""simple docstring""" from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
579
1
'''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(A ) , ...
11
import logging from transformers import PretrainedConfig lowerCamelCase__ = logging.getLogger(__name__) lowerCamelCase__ = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", } class S...
225
0
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowercase__ : Union[str, Any] ...
714
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase__ : Union[str, Any] = { "configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_A...
43
0
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a_ = '2.13.1' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('3.7'): raise ImportWarning( '...
25
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer UpperCAmelCase_ = logging.getLogger(__name__) def lowerCAmelCase_ ( ) -> Optional[Any]: '''simple docstring''' _UpperCamelCase: List[str] = argpa...
271
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A : str = logging.get_logger(__name__) A : Dict = { "facebook/dat...
5
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tok...
5
1
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow_...
59
'''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 __magic_name__ : Optional[int] = False class __SCREAMING_SNAKE_CA...
672
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _UpperCamelCase ( _...
715
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: int ): if number > 0: raise ValueError("""input must be a negative integer""" ) __SCREAMING_SNAKE_CASE : str = len(bin(_lowerCamelCase )[3:] ) __SCREAMING_SNAKE_CASE : Any = bin(abs(_lowerCamel...
178
0
'''simple docstring''' import re def a__ ( _SCREAMING_SNAKE_CASE : str ) -> str: """simple docstring""" if len(re.findall("[ATCG]" , _SCREAMING_SNAKE_CASE ) ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("Invalid Strand" ) return dna.tra...
71
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase : str = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerC...
719
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
341
0
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 TaTokenizer else: ...
481
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(10 ...
481
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ ={ "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
442
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase__ ={ "configuration_data2vec_audio": ["DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP", "Data2VecAudioConfig"], "c...
442
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def lowerCAmelCase__ ( _a : int , _a : int , _a : int , _a : int , _a : int , _a : int ): if (ksize % 2) == 0:...
568
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimeSeries...
178
0
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, ...
711
"""simple docstring""" a : str = 8.314_4598 def _SCREAMING_SNAKE_CASE ( _lowercase : float , _lowercase : float ) ->float: '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 ...
31
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def __snake_case ( SCREAMING_SNAKE_CASE_ : Callable[[int | float], int | float] , SCREAMING_SNAKE_CASE_ : int | float , SCREAMING_SNAKE_CASE_ : int | float , SCREAMING_SNAKE_CASE_ : int = 100 ,...
51
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""], } try: if not is_torch_available(): raise...
356
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.js...
404
"""simple docstring""" def snake_case ( ) -> Tuple: _snake_case = 0 for i in range(1 , 1001 ): total += i**i return str(lowerCAmelCase_ )[-10:] if __name__ == "__main__": print(solution())
404
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = {} class UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE_ = 'llama' SCREAMING_SNAKE_CASE_ ...
42
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerC...
1
0
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available ...
502
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_confi...
502
1
import math import qiskit def __UpperCamelCase ( _lowerCAmelCase = 1 , _lowerCAmelCase = 1 , _lowerCAmelCase = 1 ): """simple docstring""" if ( isinstance(_lowerCAmelCase , _lowerCAmelCase ) or isinstance(_lowerCAmelCase , _lowerCAmelCase ) or...
333
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase =logging.get_logger(__name__) __lowerCAmelCase ={ "microsoft/beit-base-p...
333
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_for...
431
# Function to print upper half of diamond (pyramid) def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : int ) -> Dict: for i in range(0 , UpperCAmelCase_ ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end...
431
1
def __UpperCAmelCase( lowercase_ ): _lowerCamelCase : int = len(lowercase_ ) _lowerCamelCase : str = len(matrix[0] ) _lowerCamelCase : Tuple = min(lowercase_ , lowercase_ ) for row in range(lowercase_ ): # Check if diagona...
114
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at...
114
1
'''simple docstring''' import os def _lowerCAmelCase ( ) ->Union[str, Any]: """simple docstring""" lowercase__ = os.path.dirname(os.path.realpath(lowercase ) ) lowercase__ = os.path.join(lowercase , '''triang...
318
'''simple docstring''' import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _lowerCAmelCase ( lowercase : List[Any] , lowercase : Tuple , lowercase : Union[str, Any] ...
318
1
from math import sqrt def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> Optional[int]: 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 return False ...
579
'''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 UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : ...
365
0
'''simple docstring''' import os def SCREAMING_SNAKE_CASE ( ): with open(os.path.dirname(a_ ) + '/p022_names.txt' ) as file: __a = str(file.readlines()[0] ) __a = names.replace('"' , '' ).split(',' ) names.sort() __a = 0 _...
490
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_d...
490
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, tra...
34
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequ...
624
0
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from t...
712
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class snake_case ( ...
445
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor A_ : str ...
265
"""simple docstring""" def __snake_case ( __A : int , __A : int ) -> float: '''simple docstring''' return base * power(__A , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent us...
265
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { "configuration_convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE...
599
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - #...
599
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_availab...
53
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_v...
158
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType _...
348
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCamelCase ( _A , _A=7 ) -> List[str]: lowercase : Any = None if token is not None: lowercase ...
348
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-e...
94
'''simple docstring''' from __future__ import annotations def UpperCamelCase__ ( __magic_name__ : list ) -> float: '''simple docstring''' if not nums: raise ValueError("""List is empty""" ) return sum(__magic_name__ ) / len(__magic_name__ ) if __name_...
38
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
706
"""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 ...
349
0