code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import os def lowercase ( ) -> Union[str, Any]: __a = os.path.dirname(os.path.realpath(lowerCAmelCase__ ) ) __a = os.path.join(lowerCAmelCase__ , '''triangle.txt''' ) with open(lowerCAmelCase__ ) as f: __a...
45
"""simple docstring""" def lowercase ( lowerCAmelCase__ : str ) -> list: if n_term == "": return [] __a = [] for temp in range(int(lowerCAmelCase__ ) ): series.append(f'''1/{temp + 1}''' if series else '''1''' ) return series if __name...
45
1
"""simple docstring""" from __future__ import annotations import math __UpperCamelCase = '''2020.9.26''' __UpperCamelCase = '''xcodz-dot, cclaus, dhruvmanila''' def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAme...
312
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import Mvp...
312
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase__ : int = { 'configuration_conditional_detr': [ 'CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Con...
324
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .t...
324
1
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase__ = logging.g...
119
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'tokenization_transfo_xl': ['TransfoXLCorpus', '...
119
1
"""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/LICENS...
54
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils im...
315
0
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class UpperCamelCase__( unittest.TestCase ): def a__( self : Optional[int] )-> List[Any]: """simple docstring""" UpperCAmelCase ...
91
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch...
91
1
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py a_ ...
330
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_para...
330
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from...
196
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCamelCase : List[Any] =logging.get_logger(__name__) lowerCamelCase : Optional[Any] =...
196
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) a_ : Union[str, Any] = { """configuration_trocr""": ["""TROCR_PRE...
75
from __future__ import annotations def snake_case_ ( snake_case , snake_case ) -> bool: if len(snake_case ) == 0: return False lowercase__: Any = len(snake_case ) // 2 if a_list[midpoint] == item: return True ...
196
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ = { "configuration_al...
354
"""simple docstring""" from __future__ import annotations import math class __lowerCamelCase : '''simple docstring''' def __init__( self : Dict , a_ : int ): lowerCAmelCase_ : Union[str, Any] = size # approximate the ove...
161
0
'''simple docstring''' from collections import deque class _UpperCAmelCase : """simple docstring""" def __init__( self : List[Any] , __UpperCAmelCase : str , __UpperCAmelCase : int , __UpperCAmelCase : int ): '''simple docstring''' ...
79
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a : L...
114
0
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers impor...
46
'''simple docstring''' import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxrun...
46
1
"""simple docstring""" import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.model...
109
"""simple docstring""" 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 e...
264
0
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __lowerCamelCase : Dict = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (trapm...
358
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : Any = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConfig""", """Instr...
286
0
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorForm...
134
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) __snake_case : Any = pytest.mark.integration @pytest.mark.parametrize("""p...
134
1
import operator as op _lowerCamelCase : int = "scaler.pt" _lowerCamelCase : Any = "pytorch_model" _lowerCamelCase : int = "random_states" _lowerCamelCase : str = "optimizer" _lowerCamelCase : Dict = "schedu...
369
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : str = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_AR...
99
0
from __future__ import annotations import math __a :Tuple = '2020.9.26' __a :Any = 'xcodz-dot, cclaus, dhruvmanila' def __snake_case ( __UpperCamelCase : float ,__UpperCamelCase : float ,__UpperCamelCase : float ,__UpperCa...
312
def __snake_case ( __UpperCamelCase : int = 1000 ): """simple docstring""" return sum(e for e in range(3 ,__UpperCamelCase ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"{solution() = }")
312
1
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
370
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCAmelCase__ : __a = 42 __a = 42 class lowerCAmelCase__ : ...
40
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
119
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCAmelCase = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLConfig'''], '''tokenization_transfo_xl'''...
119
1
"""simple docstring""" import copy import re class _UpperCAmelCase : """simple docstring""" a_ = '''hp''' a_ = {} a_ = None @classmethod def lowercase ( cls : str , lowerCAmelCase_ : Optional[int] , lowerCAmelCase_ : Dict ) -> ...
355
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils....
207
0
"""simple docstring""" 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 Tokeni...
91
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, ...
91
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available A: List[Any] = { "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig", "Gro...
76
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer A: int = logging.get_logger(__name__) ...
76
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __a ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self ) -> str: '''simple docstring''' lowercase__: List[str] = [ 'safety_ch...
196
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_mode...
196
1
"""simple docstring""" from __future__ import annotations from typing import Any class a__ : def __init__( self , A = 6 ) -> None: '''simple docstring''' a = None a = None self.create_linked_list(A ) def...
368
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> list[int]: a = 2 a = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(__UpperCamelCase) if n...
180
0
'''simple docstring''' 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_extractio...
89
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings...
161
0
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, requi...
356
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_...
328
0
"""simple docstring""" import torch def UpperCAmelCase__ ( ): '''simple docstring''' if torch.cuda.is_available(): lowerCAmelCase = torch.cuda.device_count() else: lowerCAmelCase = 0 print(F'Successfully ran on {...
46
"""simple docstring""" import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torc...
46
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : list[list[int]] ) -> int: """simple docstring""" def update_area_of_max_square(_SCREAMING_SNAKE_CASE : int , _SCREAMING_SN...
67
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" UpperCAmelCase_ : str = len(_SCREAMING_SNAKE_CASE ) for _ in range(_SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 ...
67
1
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers.uti...
43
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers lowerCamelCase_ : List[str] = [int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def UpperCAmelCase__ ( ): """simple docstring""" A_ : Union[str, Any] = os...
286
0
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, 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_te...
60
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 if is_torch_availab...
60
1
'''simple docstring''' snake_case_ : str = 9.8_06_65 def A__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = g ): if fluid_density <= 0: raise ValueError('Impossible fluid density' ) if volume < 0: raise ValueError('Impossible Object...
83
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
99
0
'''simple docstring''' import argparse _SCREAMING_SNAKE_CASE = "docs/source/_static/js/custom.js" def __lowerCamelCase ( __lowerCAmelCase : Dict ) -> int: with open(__lowerCAmelCase , encoding="""utf-8""" , newline="""\n""" )...
3
'''simple docstring''' def __lowerCamelCase ( __lowerCAmelCase : int ) -> int: if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < 0: ...
3
1
def lowerCamelCase ( ): '''simple docstring''' return 1 def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' return 0 if x...
43
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example __lowercase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
40
0
"""simple docstring""" def a_ ( _lowercase ): def merge(_lowercase , _lowercase ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) ...
361
"""simple docstring""" import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def a_ ( _lowercase , _lowercase , _l...
128
0
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( B...
0
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig...
207
0
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _a : List[Any] = datasets.load_iris() _a : Dict = np.array(data['data']) _a : int = np.array(data['target']) _a : ...
359
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
126
0
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCamelCase__ ( _a , _a): # Load checkpoint SCREAMING_SNAKE_CA...
76
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at https://huggingface.co/models?filter=vit_msn ...
76
1
'''simple docstring''' import os def __magic_name__ ( ) -> Any: '''simple docstring''' snake_case_ = os.path.dirname(os.path.realpath(__UpperCAmelCase ) ) snake_case_ = os.path.join(__UpperCAmelCase, '''triangle.txt''' ) with open(__Uppe...
72
'''simple docstring''' import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_C...
72
1
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version a__ : Optional[int] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from...
161
def snake_case ( snake_case__ :str = "The quick brown fox jumps over the lazy dog" , ) -> bool: _A = set() # Replace all the whitespace in our sentence _A = input_str.replace(""" """ , """""") for alpha in input_str: if "a" <= alpha.l...
180
0
"""simple docstring""" # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly forma...
11
"""simple docstring""" from math import factorial, radians def lowercase ( lowerCAmelCase__ : float , lowerCAmelCase__ : int = 18 , lowerCAmelCase__ : int = 10 ) -> float: __a = angle_in_degrees - ((angle_in_degrees // 3_60.0) * 3_60.0) # Co...
11
1
'''simple docstring''' import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class SCREAMING_SNAKE_CASE ( unittest.TestCase ): """simple docstring""" def A ( self : ...
28
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Any = logging.get_logger(__name__) lowercase__ : Tuple = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", "...
328
0
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter, ...
362
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_para...
23
0
'''simple docstring''' import math from collections.abc import Callable def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> float: __lowerCamelCase = xa __lowerCamelCase = xa while True: if x_n == x_na or function(UpperCamelCase__ )...
67
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
67
1
"""simple docstring""" def __lowerCAmelCase ( lowercase : str ) -> bool: """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) snake_case : Any = sorted(string.lower(...
368
"""simple docstring""" import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccum...
112
0
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import Ba...
60
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice...
60
1
def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive") lowercase__ : Tuple = str(bin(_lowerCamelCase))[2:] # remove the leading "0b" lowercase__ : List...
333
import argparse import datetime def lowercase_ ( _lowerCamelCase : str): lowercase__ : Optional[Any] = { "0": "Sunday", "1": "Monday", "2": "Tuesday", "3": "Wednesday", "4": "Thursday", "5": "Friday", "6": "Saturda...
333
1
'''simple docstring''' import argparse lowercase : Dict = 'docs/source/_static/js/custom.js' def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' with open(snake_case__ , encoding='''utf-8''' , newline='''\n''' ) as f: ...
3
'''simple docstring''' import os def lowerCAmelCase_ ( ): '''simple docstring''' A : List[Any] = os.path.join(os.path.dirname(snake_case__ ) , '''num.txt''' ) with open(snake_case__ ) as file_hand: return str(sum(...
3
1
'''simple docstring''' from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin...
361
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "RUCAIBox/mvp": "https://huggingface.co/RUCAIBox/mvp/resolve/main...
3
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A_ = {"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """D...
64
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
0
'''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/...
55
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def a_ ( lowerCamelCase : Iterable[str] , lowerCamelCase : int ): lowerCAmelCase = iter(lowerCamelCase ) while True: lowerCAmelCase...
55
1
def __lowerCAmelCase ( a__ , a__ , a__ ) -> list: __a = len(a__ ) __a = [[0] * n for i in range(a__ )] for i in range(a__ ): __a = y_points[i] for i in range(2 , a__ ): for j in range(a__ , a__ ): ...
6
"""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 accelerat...
126
0
"""simple docstring""" import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import...
350
import numpy # List of input, output pairs a_ = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) a_ = (((515, 22, 13), 555), ((61, 35, 49), 150)) a_ = [2, 4, 1, 5] a_ = len(train_data) a_ = 0.009 def __lowercase ( lowe...
50
0
"""simple docstring""" from math import ceil def snake_case_ ( A_ : Dict, A_ : Tuple ): '''simple docstring''' _lowerCamelCase : List[Any] = list(range(0, A_ ) ) _lowerCamelCase : List[Any] = [item for s...
72
"""simple docstring""" def snake_case_ ( A_ : list[int], A_ : str ): '''simple docstring''' _lowerCamelCase : Tuple = int(A_ ) # Initialize Result _lowerCamelCase : Dict = [] # Traverse through all deno...
72
1
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 im...
122
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __snake_case : Any = """https://www.indeed.co.in/jobs?q=mobile+app+development&l=""" def _UpperCamelCase ( UpperCamelCase_ : str = "mumbai" ...
122
1
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thin...
11
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json', # See all ViT MAE models at https://huggingf...
11
1
def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00 ): __UpperCamelCase : Tuple = n * (n + 1) * (2 * n + 1) / 6 __UpperCamelCase : List[str] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F"""{s...
171
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, ResNetC...
171
1
"""simple docstring""" from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, S...
78
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake UpperCamelCase__: Tuple = numpy.array([0, 0]) UpperCamelCase__: Union[str, Any] = numpy.array([0.5, 0.8660254]) ...
23
0
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast __a = datasets.utils.logging.get_logger(__name__) @dataclass class __a( datasets.BuilderConfig ): ...
360
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, BlipImagePro...
235
0
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase_ ( lowerCamelCase__ ): ...
0
'''simple docstring''' from math import ceil, sqrt def lowerCAmelCase_ ( _lowerCamelCase: int = 1_00_00_00 ): __SCREAMING_SNAKE_CASE : Union[str, Any] = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __SCREAMING_SNAKE_C...
112
0
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def A_ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = None ): if version.parse(hfh.__version__ ).release < version.parse("0.11.0" ...
356
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowercase ( tf.keras.optimizers.schedules.LearningRateSchedule ): "...
127
0
def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __UpperCAmelCase = str(bin(SCREAMING_SNAKE_CASE ) )[2:] # r...
333
import math import sys def __a ( SCREAMING_SNAKE_CASE ) -> int: '''simple docstring''' if number != int(SCREAMING_SNAKE_CASE ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''th...
333
1
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig ...
359
from math import ceil def lowerCamelCase_ ( lowerCAmelCase: Tuple , lowerCAmelCase: Union[str, Any] )-> str: _snake_case : Union[str, Any] = list(range(0 , lowerCAmelCase ) ) _snake_case : int = [item for sublist in list(device...
260
0
from scipy.stats import pearsonr import datasets __UpperCamelCase : Optional[int] = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on ...
182
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingS...
3
0
from collections.abc import Sequence def lowercase ( _SCREAMING_SNAKE_CASE : Sequence[int] | None = None ): '''simple docstring''' if nums is None or not nums: raise ValueError('''Input sequence should not be empty''' ) _UpperCAmelCase ...
363
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : Optional[Any] = { "configuration_funnel": ["FUNNEL_PRETRAI...
326
0
'''simple docstring''' from __future__ import annotations a_ : int = """#""" class snake_case : """simple docstring""" def __init__( self ): """simple docstring""" lowerCamelCase_ = {} def snake_case ( ...
55
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStr...
55
1
import unittest from transformers import BigBirdConfig, 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 from transformers.models.big_bird.model...
99
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 ..models.auto.modeling...
99
1
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from t...
109
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepie...
50
0
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports _SCREAMING_SNAKE_CASE = ''' import os ''' _SCREAMING_SNAKE_CASE = ''' def foo(): import os return False ''' _SCREAMING_SNAKE_CASE = ''' def foo(): ...
217
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { '''Intel/dpt-large''': '''https://huggingface....
217
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from tr...
122
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = { '''configuration_megatron_bert''': ['''MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegatronBertConfig'''], } try: if not is_torch_available(): raise Opt...
122
1
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 lowerCAmelCase_ = logging.getLogger(__name__) ...
279
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __lowerCAmelCase ( unittest.TestCase ): @pro...
279
1
"""simple docstring""" _A = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _A = [{"""type""": "...
171
"""simple docstring""" import os from datetime import datetime as dt from github import Github _A = [ """good first issue""", """feature request""", """wip""", ] def a__ ( ) -> str: UpperCAmelCase__ : Union[str, Any] = Github(os.environ["""GITHUB_TOKEN"""] ...
171
1
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCAmelCase_( lowercase_ : str , low...
73
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : List[str] = { '''configuration_vision_encoder_decoder''': ['''Vis...
73
1
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class lowercase_ ( nn.Module ): '''simple docstring''' def __init__( self : Dict , _UpperCAmelCase : Tu...
315
import requests a__ = '''YOUR API KEY''' def __UpperCAmelCase ( __a : str ,__a : str = giphy_api_key ) -> list: """simple docstring""" _a : Optional[Any] = '''+'''.join(query.split() ) _a : Union[str, Any] = F"""https://api.giphy.co...
235
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test,...
352
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_u...
220
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase = { '''configuration_upernet''': ['''UperNetConfig'''], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable()...
69
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached...
127
0
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def UpperCamelCase ( lowerCAmelCase__="ro" , lowerCAmelCase__="en" , lowerCAmelCase__="wmt16" , lowerCAmelCase__=None ): '''simple docstring''' try: import datasets except (...
352
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class lowercase ( SCREAMING_SNAKE_CASE__ ): lowe...
97
0
"""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.activations import gelu_new, gelu_python, get_activation @require_torch class _...
84
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Tuple = logging.get_logger(__name__) _...
260
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : str , lowerCAmelCase : Optional[int] ) -> Optional[Any]: """simple docst...
352
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position __UpperCAmelCase = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse("""3.7""...
139
0
'''simple docstring''' import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __a = logging.get_logger(__name__) def __snake_case( _lowerCAmelCase , _lowerCAme...
35
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 _UpperCamelCase = 4 _UpperCamelCase = 3 class _lowerCamelCase ( a ): """s...
326
0
__A = 'Input must be a string of 8 numbers plus letter' __A = 'TRWAGMYFPDXBNJZSQVHLCKE' def __A ( _lowercase ): '''simple docstring''' if not isinstance(_lowercase , _lowercase ): _A = f"""Expected string as input, found {type(_lowerc...
357
from __future__ import annotations import math def __A ( _lowercase , _lowercase , _lowercase , _lowercase , _lowercase ): '''simple docstring''' if depth < 0: raise ValueError('''Depth cannot be less than 0''' ) if not scores: ...
75
0
from torch import nn def A_ ( A__ ) -> Dict: if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F'Unsupported activation...
99
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Co...
99
1
from datetime import datetime as dt import os from github import Github UpperCamelCase__ = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def _UpperCamelCase (): """simple docstring""" ...
87
import json import os import torch from diffusers import UNetaDModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) def _UpperCamelCase (a__ :int...
87
1
"""simple docstring""" from __future__ import annotations import typing from collections import Counter def a__ ( __SCREAMING_SNAKE_CASE ) -> typing.Counter[int]: __lowerCAmelCase: typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): ...
217
"""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 tra...
217
1
"""simple docstring""" from math import factorial _a = {str(digit): factorial(digit) for digit in range(10)} def lowerCamelCase__ ( __snake_case ) -> str: """simple docstring""" if not isinstance(A_, A_ ): raise TypeE...
358
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""...
100
0
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) snake_case_ = str(SCREAMING_SNAKE_CASE__ ) snake_case_...
8
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __lowerCAmelCase ( _a ): lowerCamelCase_ : int = '''''' lowerCamelCase_ : str = ( ...
279
0
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _UpperCAmelCase : List[Any] = [ """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phon...
200
def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def __lowerCamelCase ( ): '''simple docstring''' assert nand_gate(0 , 0 ) == ...
200
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> List[Any]: monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set() ) @pytest.fixture...
73
from math import isclose, sqrt def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> tuple[float, float, float]: __lowerCamelCase : Tuple = point_y / 4 / point_x __lowerCamelCase : Tuple = 2 * normal_gradient / (1...
73
1
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 compute_effective_axis_dimension from ...ut...
370
def _a ( SCREAMING_SNAKE_CASE__ : int = 50_00_00_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ : str = set() SCREAMING_SNAKE_CASE__ : Dict = int((limit - 24) ** (1 / 2) ) SCREAMING_SNAK...
191
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor _UpperCamelCase : int = logging.get_logger(__name__) class a ( a_ ): def __init__( self , *_lowerCamelCase , **_lowerCamelCase ): ...
220
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is...
220
1
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowerCamelCase_( _lowerCamelCase ) ...
358
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def lowerCamelCase_( _lowerCamelCase ) -> str: '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("Undefined for non-integers...
340
0
from datetime import datetime import matplotlib.pyplot as plt import torch def UpperCamelCase( __UpperCamelCase : Tuple ): for param in module.parameters(): lowerCAmelCase_ : Dict = False def UpperCamelCase( ): lowerCAmelCase_ : List[Any] = '''cuda''' if...
103
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformer...
97
0
"""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_CO...
362
"""simple docstring""" import os from math import logaa def _snake_case ( lowercase__ : str = "base_exp.txt" ) -> int: '''simple docstring''' lowerCAmelCase_ :float = 0 lowerCAmelCase_ :Union[str, Any] = 0 for i, line ...
1
0
'''simple docstring''' def A_ ( snake_case ): SCREAMING_SNAKE_CASE:int = set() # edges = list of graph's edges SCREAMING_SNAKE_CASE:Any = get_edges(snake_case ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_n...
139
'''simple docstring''' from __future__ import annotations A_ = list[list[int]] # assigning initial values to the grid A_ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3,...
139
1
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
70
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
70
1
'''simple docstring''' import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = """▁...
141
'''simple docstring''' import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, ...
75
0
"""simple docstring""" 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_ = { '''xlm-roberta-bas...
253
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping lowerCamelCase_ = tuple[int, int] class UpperCamelCase_ : def __init__( self : List[Any] , lowerCAmelCase_ : set[int] , lowerCAmelCase_ : Mapping[EdgeT,...
253
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.js...
87
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''YituTech/conv-bert-base''': '''h...
87
1
import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availabl...
362
from __future__ import annotations import typing from collections import Counter def _a ( a :int ) -> typing.Counter[int]: a = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(a , max_perimeter + 1 ): a ...
26
0
"""simple docstring""" from abc import ABC, abstractmethod from typing import List, Optional class __snake_case ( _lowercase): def __init__( self : str ): """simple docstring""" self.test() def SCREAMING_SNAKE_CASE ( self : ...
72
"""simple docstring""" from collections import defaultdict def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = first_str.lower().strip() __SCREAMING_SNAKE_CASE = second_str.lower().strip() # Remove whitespace __SCREAMING_SNAKE_CA...
100
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available, s...
90
def __UpperCamelCase ( lowerCAmelCase__ : list ): def merge(lowerCAmelCase__ : list , lowerCAmelCase__ : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right re...
90
1