code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common i...
31
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Arr...
113
0
def lowerCAmelCase ( _lowerCAmelCase : int , _lowerCAmelCase : int ): """simple docstring""" return x if y == 0 else greatest_common_divisor(_lowerCAmelCase , x % y ) def lowerCAmelCase ( _lowerCAmelCase : int , _lowerCAmelCase ...
717
import math def lowerCAmelCase ( _lowerCAmelCase : int ): """simple docstring""" UpperCAmelCase__ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_lowerCAmelCase ) def lowerCAmelCase ( _lowerCAmelCase : float = 1...
364
0
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> Lis...
690
"""simple docstring""" def __snake_case ( UpperCamelCase__ ) -> list[int]: """simple docstring""" A = [0 for i in range(len(UpperCamelCase__ ) )] # initialize interval's left pointer and right pointer A , A = 0, 0 for i in ran...
690
1
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __A : Tuple = collections.namedtuple("""_Datasets""", ["""train"...
450
from __future__ import annotations def lowerCamelCase_ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' create_state_space_tree(SCREAMING_SNAKE_CASE , [] , 0 , [0 for i in range(len(SCREAMING_SNAKE_CASE ) )] ) def lowerCamelCase_ ( SCREAMING_SNAKE_CASE , SCREAMIN...
450
1
"""simple docstring""" 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, pr...
102
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCAmelCase ( UpperCAmelCase_ ...
126
0
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class _lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" ...
718
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils im...
408
0
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging...
414
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging...
414
1
"""simple docstring""" import argparse import json import os import re from collections import OrderedDict from os.path import basename, dirname import fairseq import torch from fairseq import hub_utils from fairseq.data.dictionary import Dictionary from transformers import FSMTConfig, FSMTForConditionalG...
706
"""simple docstring""" import unittest from knapsack import greedy_knapsack as kp class a ( unittest.TestCase ): def UpperCamelCase ( self : Tuple ) -> str: lowerCamelCase_ = [10, 20, 30, 40, 50, 60] lowerCamelCase_...
137
0
from __future__ import annotations import math def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> list[int]: """simple docstring""" if num <= 0: UpperCamelCase_ = f"{num}: Invalid input, please enter a positive integer." raise ValueError(S...
628
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def lowerCAmelCase( SCREAMING_SNAKE_CAS...
628
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : int = logging.get_logger(__name__) UpperCAmelCase__ : Dict = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.c...
702
"""simple docstring""" def lowercase_ ( _snake_case ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE__ : List[str] = 1 SCREAMING_SNAKE_CASE__ : List[Any] = 1 while repunit: SCREAMING_SNAKE_CASE_...
545
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE :Dict = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokenization_ctrl""": ["""CTRLT...
628
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @r...
628
1
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_model_forward ...
718
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, ) UpperCamelCase_ = { 'configuration_albert': ['ALBERT_PRETRAINE...
142
0
'''simple docstring''' 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 TFModelT...
158
'''simple docstring''' from __future__ import annotations def A_ ( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ) -> list: __SCREAMING_SNAKE_CASE : Optio...
158
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): ...
707
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { "configuration_blip_2": [ "BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Blip2Config", "Blip2QFormerConfig", "Blip2VisionCon...
301
0
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _low...
89
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_...
57
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Tuple = logging.get_logger(__name__) class __A (__magic_name__ ): snake_case :Optional[int] = "encoder-decoder" snake_case :List[Any] ...
706
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): impor...
10
0
from math import factorial def __a ( __UpperCAmelCase : Dict = 100 ) -> int: """simple docstring""" return sum(int(UpperCamelCase__ ) for x in str(factorial(UpperCamelCase__ ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the...
488
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = { '''configuration_electra''': ['''ELECTRA_PRETRAINE...
657
0
import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _a ( SCRE...
207
def SCREAMING_SNAKE_CASE( __UpperCamelCase ) -> float: a__ : Optional[Any] = 0 while len(__UpperCamelCase ) > 1: a__ : str = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): a__ : List[str] = file...
207
1
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline 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_params imp...
70
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResa...
471
0
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(_SCREAMING_SNAKE_CASE ) * abs(_SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __UpperCamelCase : Optional[int] = models.Sequent...
248
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __UpperCamelCase : List[Any] = logging.get_logger(__name__) def A ( _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : Union[s...
248
1
from __future__ import annotations def a__ ( a ) -> int: if not nums: return 0 A_ : Tuple = nums[0] A_ : int = 0 for num in nums[1:]: A_ , A_ : Union[str, Any] = ( ...
236
import heapq def a__ ( a ) -> set[int]: A_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, s...
236
1
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hu...
11
__UpperCamelCase = 2_5_6 # Modulus to hash a string __UpperCamelCase = 1_0_0_0_0_0_3 def UpperCamelCase_( _A :str , _A :str )-> bool: UpperCamelCase__ = len(_A ) UpperCamelCase__ = len(_A ) if p_len > t_len: return False UpperCamelCa...
551
0
"""simple docstring""" from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake __SCREAMING_SNAKE_CASE = numpy.array([0, 0]) __SCREAMING_SNAKE_CASE = numpy.array([0.5, 0.8_66_02_54]) __SCREAMING_SNAKE_CASE = ...
395
"""simple docstring""" import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def A_ ( __lowercase ): monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set() ) @pytest.fixture def A_ ( __lowercase )...
395
1
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
32
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() lowerCamelCase : Optional[int] = logging...
587
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImg...
566
'''simple docstring''' import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transf...
566
1
from __future__ import annotations def UpperCamelCase ( _UpperCAmelCase : str , _UpperCAmelCase : list[str] | None = None ) -> list[list[str]]: '''simple docstring''' _lowercase : Dict = word_bank or [] # create a table _lowercase : int...
461
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import torch.nn as ...
461
1
def _a ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__UpperCamelCase , n - 1 , __UpperCamelCase ) * a) % mod else: a_ : Any = binary_exponentiation(__Upp...
715
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''facebook/convnextv2-tiny-1k-224''':...
478
0
"""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, ...
552
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) _lowercase = { '''iou_prediction_head.lay...
659
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : str =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Optional[int] ={ '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/confi...
72
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Union[str, Any] =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Tuple ={ '''google/pix2struct-textcaps-b...
72
1
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def UpperCAmelCase__ (snake_case__ : int = 8 ): """simple docstring""" _snake_case : Dict = ascii_lette...
609
def lowerCamelCase_ ( UpperCamelCase__ : str ) -> bool: """simple docstring""" __lowerCamelCase = 0 for ch in input_str: __lowerCamelCase = ord(UpperCamelCase__ ) __lowerCamelCase = pow(2 , UpperCa...
469
0
"""simple docstring""" def UpperCamelCase ( _A : Dict = 10 ) -> str: if not isinstance(_A , _A ) or n < 0: raise ValueError("""Invalid input""" ) lowercase : List[str] = 10**n lowercase : Optional[int] = 28_433 * (pow(2...
706
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCamelCase ( _A , _A , _A = 1 / sqrt(2 ) ) -> IIRFilter: lowercase : Optional[int] = tau * frequency / samplerate lowercase ...
348
0
def A ( snake_case__ : int = 10**12 ) -> Tuple: '''simple docstring''' __snake_case = 1 __snake_case = 0 __snake_case = 1 __snake_case = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * numerator numerator +...
313
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, l...
603
0
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class UpperCamelCase_ : pass
541
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get...
541
1
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/niels/...
290
from collections.abc import Callable def lowerCamelCase__ ( __lowerCAmelCase : Callable[[float], float] , __lowerCAmelCase : float , __lowerCAmelCase : float ): """simple docstring""" lowerCAmelCase_ = a lowerCAmelCase_ =...
290
1
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgume...
11
'''simple docstring''' def A_ ( _lowerCAmelCase : float ): """simple docstring""" return 10 - x * x def A_ ( _lowerCAmelCase : float , _lowerCAmelCase : float ): """simple docstring""" if equation(_lowerCAmelCase ) *...
11
1
"""simple docstring""" from math import pi def _lowerCamelCase ( __a, __a ): return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
626
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.di...
626
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase__ : List[Any] = logging.get_logger(__name__) UpperCamelCase__ : Optional[Any] = { "...
486
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : List[Any] = {"""configuration_sew""": ["""SEW_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SEWConfig"""]} try: if not is_torch_available(): raise ...
486
1
from sklearn.metrics import matthews_corrcoef import datasets _lowercase = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and false pos...
659
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientSt...
583
0
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 f...
72
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, ImageClassifierOutp...
72
1
__snake_case = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)] def _lowercase ( SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" UpperCamelCase = 0 while number: # Increased Speed Slightly by checking every...
386
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __snake_case = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.m...
386
1
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase__ ( __lowerCAmelCase ): """s...
715
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor...
682
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
327
import unittest from transformers import DonutProcessor lowercase : Optional[int] = "naver-clova-ix/donut-base" class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" def __lowerCamelCase ( self ) -> Optional[int]: ...
327
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = {} try: if not is_sentencepiece_available(): raise...
599
'''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/LI...
599
1
"""simple docstring""" class _lowerCAmelCase : def __init__( self , UpperCamelCase__ = "" , UpperCamelCase__ = False ) -> Any: '''simple docstring''' snake_case : dict[str, RadixNode] = {} # A node will be a leaf if the tree con...
178
def _snake_case ( lowerCAmelCase : str , lowerCAmelCase : str ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Any = len(lowerCAmelCase ) SCREAMING_SNAKE_CASE_ : Optional[Any] = len(lowerCAmelCase ) SCREAMING_SNAKE_CASE_ : ...
216
0
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger _a: int = """<<<<<<< This should probably be modified because it mentions: """ _a: Union[str, Any] = """======...
268
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a: List[Any] = logging.get_logger(__name__) _a: List[str] ...
268
1
'''simple docstring''' from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 _a : str = { # 1536-bit 5: { ...
689
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block...
689
1
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def lowerCamelCase_ ( lowercase__ , lowercase__): if inductance <= 0: raise ValueError("Inductance cannot be 0 or negative") elif capacitance <= 0: raise ValueError("Capacitance cannot be 0 or...
706
'''simple docstring''' class lowercase : '''simple docstring''' def __init__( self : Union[str, Any] ) -> None: '''simple docstring''' lowerCamelCase__ = {} # Mapping from char to TrieNode lowerCamelCase__ = False def a_...
187
0
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class a ( unittest.TestCase ): def lowerCAmelCase_ ( self ...
277
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __UpperCAmelCase ( lowercase ,lowercase ,lowercase = False ): """simple docstring""" if radian_mode: return [magnitude * cos(...
277
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : List[str] = logging.get_logger(__name__) __lowerCAmelCase : str = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See all CANIN...
709
from __future__ import annotations def UpperCAmelCase_ ( __lowerCAmelCase ) -> int: if not nums: return 0 __lowercase : List[Any] = nums[0] __lowercase : Union[str, Any] = 0 for num in nums[1:]: __lowercase , __lowercase : ...
284
0
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('''repo_id''' , ['''canonical_dataset_name''', '''org-name/dataset-name'''] ) @pytest.mark.parametrize('''path''' , ['''filename.csv''', '''filename with blanks.csv'''] ) @pytest.ma...
590
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_...
590
1
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class UpperCamelCase__ : def UpperCAmelCase__ ( self : Tuple , UpperCamelCase__ : List[Any] ): '''sim...
704
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar a = TypeVar('T') class UpperCamelCase__ ( Generic[T] ): __SCREAMING_SNAKE_CASE : deque[T] # Cache store of keys __SCREAMING_SNAKE_CASE : set[T] # Ref...
650
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtrac...
12
from collections import defaultdict from math import ceil, sqrt def __lowerCAmelCase( _SCREAMING_SNAKE_CASE = 1_000_000 , _SCREAMING_SNAKE_CASE = 10 ) -> int: """simple docstring""" _A = defaultdict(_SCREAMING_SNAKE_CASE ) ...
27
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCAmelCase: Any = logging.get_logger(__name__) lowerCAmelCase: List[Any] = { 'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.j...
705
'''simple docstring''' from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowerCAmelCase: List[str] = TypeVar('T') def lowerCamelCase__ ( _A ): return (position - 1) // 2 def lowerCamelCase__ ( _A ): return (2 * position) + 1 def ...
195
0
'''simple docstring''' import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sq...
44
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
0
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hub_u...
700
"""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_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE_ = logging.get_logger(__na...
579
0
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenizati...
67
def SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" def merge(UpperCAmelCase__ ,UpperCAmelCase__ ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yi...
605
0
import functools def UpperCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' _A= len(lowerCAmelCase_ ) _A= len(lowerCAmelCase_ ) @functools.cache def min_distance(lowerCAmelCase_ , lowerCAmelCase...
709
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoMo...
476
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See all ...
18
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : Union[str, Any] ...
348
0
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) UpperCamelCase__ = logging.getLogger(...
634
def UpperCAmelCase__ ( lowercase__ , lowercase__ ) -> int: if len(lowercase__ ) != len(lowercase__ ): raise ValueError("""String lengths must match!""" ) __lowercase = 0 for chara, chara in zip(lowercase__ , lowercase__ ): ...
634
1
'''simple docstring''' UpperCAmelCase_ : List[Any] = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] UpperC...
44
from __future__ import annotations def _UpperCAmelCase ( a__): '''simple docstring''' if len(a__) == 0: return [] a_ , a_ : List[Any] = min(a__), max(a__) a_ : Tuple = int(max_value - min_value) + 1 a_ : list[list] = ...
540
0
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common i...
701
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __lowercase = 299_792_458 # Symbols __lowercase , __lowercase , __lowercase , __lowercase = symbols('''ct x y z''') def low...
296
0
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available()...
111
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', 'BlipConfig', 'BlipTextConfi...
417
0
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoCon...
318
'''simple docstring''' import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutpu...
318
1
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class __lowerCAmelCase ( UpperCAmelCase_ , unittest.TestCase ): ...
9
import math def UpperCAmelCase ( UpperCAmelCase )-> int: '''simple docstring''' if not isinstance(UpperCAmelCase ,UpperCAmelCase ): SCREAMING_SNAKE_CASE_ = f'''Input value of [number={number}] must be an integer''' raise TypeError(UpperCA...
393
0
def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase = " "): SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = 0 for index, char in enumerate(_UpperCAmelCase): if char == separator: split_words.append(string[last_index:index]) SCREAMING_SNAKE_CASE ...
707
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 _snake_case ( A__ ): _lowercase : Union[str, Any] ...
444
0
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase :Tuple = { '''configuration_vivit''': ['''VIVIT_PRETRAINED_CONFIG_ARCHIVE...
667
"""simple docstring""" import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : ...
4
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( UpperCamelCase_ ): a_ : Optional[Any] = (EulerDiscreteScheduler,) a_ : Tuple = 10 def A_...
712
# 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 TensorFormatter if TYPE_CHECKING...
142
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: SCREAMI...
419
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass cla...
681
0
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class A_ : """simple docstring""" def __init__( self : Tuple ,__A : int=2 ,__A : List[Any]=3 ,__A ...
535
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 ...
535
1
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase , __l...
33
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, ...
678
0
'''simple docstring''' import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __UpperCamelCase ( __lowerCamelCase : Optional[int] ) -> int: '''simple docstring''' monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_d...
721
'''simple docstring''' lowercase__ = 256 # Modulus to hash a string lowercase__ = 1_000_003 def __UpperCamelCase ( __lowerCamelCase : str , __lowerCamelCase : str ) -> bool: '''simple docstring''' _a = len(__lowerCamelCase ) _a ...
276
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase : Tuple = { 'edbeeching/decision-transformer-gym-hopper-medium': ( 'https://huggingface.co/edbeeching/decis...
519
from __future__ import annotations from typing import Any class __UpperCamelCase : """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = 0 ) -> None: a__ , a__ = row, column a__ = [[default_va...
194
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Dict = logging.get_logger(__name__) snake_case__ : int = { 's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json', } class _a ( _A ): ...
717
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() ...
592
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNo...
12
"""simple docstring""" import requests def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' UpperCAmelCase__ : Tuple = {"""Content-Type""": """application/json"""} UpperCAmelCase__ : Optional[Any] = requ...
65
0
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : str, lowerCamelCase : Any, lowerCamelCase : Tuple )-> None:...
703
"""simple docstring""" def snake_case__ ( __lowerCamelCase : list[int] ): """simple docstring""" if not numbers: return 0 if not isinstance(__lowerCamelCase , (list, tuple) ) or not all( isinstance(__lowerCamelCase , __lowerCamelCase ) for number in num...
625
0
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights fr...
7
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
200
0
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# a : Tuple = [ # (stable-diffusion, HF Diffusers) ('''time_embed.0.weigh...
701
"""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...
31
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torc...
65
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME lowercase : Optional[int] = ["small", "medium", "large"] lowercase : Optional[int] = "lm_head.decoder.weight" lowercase : List[Any] = "lm_head.weight" def ...
495
0
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_lowerCamelCase ): a = ['''speech'''] def __init__( self , *a__ , **a__ ): requires_backends(self , ["""speech"""] ) class ...
481
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if i...
481
1
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union lowerCamelCase_ = TypeVar('''T''') lowerCamelCase_ = Union[List[T], Tuple[T, ...]] lowerCamelCase_ = Union[T, List[T], Dict[str, T]] lowerCamelCase_ = Union[str, bytes, os.Path...
95
def __UpperCAmelCase ( lowerCamelCase_ : List[str] , lowerCamelCase_ : Optional[Any] ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = [0 for i in range(r + 1 )] # nc0 = 1 SCREAMING_SNAKE_CASE_ : Dict = 1...
105
0
'''simple docstring''' import torch from transformers import AutoModel class SCREAMING_SNAKE_CASE__ ( torch.nn.Module ): def __init__( self , lowercase__="sayef/fsner-bert-base-uncased" ): """simple docstring""" ...
68
'''simple docstring''' def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , ) -> float:...
68
1
def SCREAMING_SNAKE_CASE__ ( snake_case__ :list , snake_case__ :list ) -> float: _validate_point(snake_case__ ) _validate_point(snake_case__ ) if len(snake_case__ ) != len(snake_case__ ): raise ValueError('Both points must be in the same n-dimensional space' ) ...
67
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : float , __UpperCamelCase : list[float] ) -> float: if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: raise ValueError('''Cash flows list cannot be empty''' ) ...
144
0
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.utils import patch_environ...
531
def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> int: """simple docstring""" assert column_title.isupper() snake_case_ = 0 snake_case_ = len(SCREAMING_SNAKE_CASE ) - 1 snake_case_ = 0 while index >= 0: snake_case_ = (ord(column_title[ind...
531
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/LICENSE-2...
95
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', } class lowerCamelCas...
201
0
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance __lowerCamelCase : str = 637_8137.0 __lowerCamelCase : List[Any] = 635_6752.31_4245 __lowerCamelCase : int = 637_8137 def A_ ( _lowerCAmelCase , _lowerCAmelCase ...
703
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __lowerCamelCase : Dict = logging.get_logger(__name__) __lo...
38
0
'''simple docstring''' from __future__ import annotations import math def _lowerCAmelCase ( lowercase : int , lowercase : int , lowercase : bool , lowercase : list[int] , lowercase : float ) ->int: """simple docstring"""...
161
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_...
161
1
"""simple docstring""" import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...
721
"""simple docstring""" def lowerCAmelCase_( SCREAMING_SNAKE_CASE ) -> bool: """simple docstring""" UpperCamelCase__ = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def lowerCAmelCase_( SCREAMING_SNAKE_CASE = 50_00 ) -> int: ...
20
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable A_ = {"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXConfig"]} try: if not is_tokenizers_availab...
604
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A_ = {"configuration_encoder_decoder": ["EncoderDecoderConfig"]} try: if not is_torch_available(): ...
604
1
from functools import reduce UpperCamelCase__ : Any = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043...
486
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def A_( A ): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.config , args.finetuning_...
486
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase : List[Any] = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['Bio...
529
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Dict = logging.get_logger(__name__) __lowerCAmelCase : int = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/m...
529
1
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , ...
230
from math import pow, sqrt def UpperCamelCase__ ( *SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : int = len(SCREAMING_SNAKE_CASE__ ) > 0 and all(value > 0.0 for value in values ) return result def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): return ( ...
230
1
"""simple docstring""" def __a ( a ): """simple docstring""" if not isinstance(a, a ): raise ValueError("check_bouncy() accepts only integer arguments" ) _a = str(a ) _a = "".join(sorted(a ) ) ...
388
"""simple docstring""" import argparse import collections import os import re 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_table.py __SCREAMING_SNAKE_CASE = """...
388
1
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
709
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def A_ ( lowercase_ , lowercase_ ) ->Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE ...
259
0
"""simple docstring""" from itertools import product def lowerCAmelCase_ ( UpperCamelCase__ : int , UpperCamelCase__ : int ): """simple docstring""" __lowercase = sides_number __lowercase = max_face_number * dice_number __lowe...
616
"""simple docstring""" from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def lowerCAmelCase_ ( UpperCamelCase__ : np.ndarray , UpperCamelCase__ : np.ndarray , UpperCamelCase__ : np.ndarray , UpperCamelCase__ : int...
616
1
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap __A = "Usage of script: script_name <size_of_canvas:int>" __A = [0] * 100 + [1] * 10 random.shuffle(choice) def lowerCAmelCase_ ( __a ) ->...
437
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __A = logging.get_logger(__name__) __A = ...
437
1
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets __lowerCamelCase = datasets.logging.get_logger(__name__) __lowerCamelCase = '\\n@inproceedings{bleurt,\n title={BLEURT: Learning Ro...
96
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tens...
646
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __UpperCamelCase ( _A : Dict ) -> int: ...
646
1
"""simple docstring""" def __snake_case ( ) -> Tuple: """simple docstring""" for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def __snake_case ( UpperCamelCase__ ) -> List[Any]: """simple docstring""" A = 1 A ...
690
"""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_mobilebert import MobileBertTokenizer UpperCamelCase : str = logging.ge...
690
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configura...
522
from ...processing_utils import ProcessorMixin class _UpperCamelCase ( _UpperCAmelCase ): """simple docstring""" __a : Tuple = '''SpeechT5FeatureExtractor''' __a : Optional[Any] = '''SpeechT5Tokenizer''' def __init__( self , lowerCAmelCas...
522
1