code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokeniz...
77
"""simple docstring""" 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, ...
617
0
"""simple docstring""" 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 impo...
707
"""simple docstring""" import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import ...
282
0
"""simple docstring""" import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() A_ = logging.get_logger(__name__) ...
29
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_bac...
195
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration lowerCamelCase_ : Optional[Any] = 5_00_00 lowerCamelCase_ : Optional[int] = 50_00 lowerCamelCase_ : int = os.path.split(__file__) lowerCamelCase_ : str ...
707
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 a...
302
0
'''simple docstring''' class _lowerCAmelCase : # Public class to implement a graph '''simple docstring''' def __init__(self , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> None: _snake_case = row _snake_case = col ...
585
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
0
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A : Union[str, Any] = logging.get_logger(__name__)...
711
'''simple docstring''' import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForCon...
163
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _snake_case : List[str] = logging.get_logger(__name__) _snake_case : str = { "SenseTime/deformable-detr": "https://huggingface.co/sensetime/defo...
81
'''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
0
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available():...
720
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: if num < 0: return False A_ = num A_ = 0 while num > 0: A_ = rev_num * 10 + (num % 10) num //= 10 return nu...
667
0
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging _snake_case : Optional[Any] = logging.get_logger(__name__) class _UpperCAmelCase ( _UpperCam...
53
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity_info() _sn...
53
1
"""simple docstring""" from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Optional[int] = [ 'good first issue', 'good second issue', 'good difficult issue', 'feature request', 'new model', 'wip', ] def a_ ( ): Upp...
703
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spe...
632
0
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_available...
256
import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): ...
256
1
'''simple docstring''' 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, prepar...
276
'''simple docstring''' def __UpperCamelCase ( __lowerCamelCase : int = 400_0000 ) -> int: '''simple docstring''' _a = [] _a , _a = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__lowerCamelCase ) _a , _a...
276
1
"""simple docstring""" import math from datetime import datetime, timedelta def lowercase_ ( _lowerCamelCase: int ) -> datetime: '''simple docstring''' __lowerCamelCase : str = year % 19 __lowerCamelCase : Dict = year % 4 __lowerCamelCase : L...
646
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp...
646
1
import math from collections.abc import Callable def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case , __snake_case ) -> Any: _UpperCAmelCase = xa _UpperCAmelCase = xa while True: if x_n == x_na or function(__snake_case )...
717
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_a...
402
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = { '''configuration_megatron_bert''': ['''MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegatronBertConfig'''], } ...
103
"""simple docstring""" import math from datetime import datetime, timedelta def __magic_name__ ( _lowerCamelCase : int ): __a : Dict = year % 1_9 __a : List[str] = year % 4 __a : Optional[Any] = year % 7 __a...
581
0
import unittest from typing import Dict, List, Optional, Union 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_in...
203
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, StableDiffusionXLImgaImgPipeline, UNetaDCo...
203
1
import argparse import struct import unittest class __UpperCamelCase : """simple docstring""" def __init__( self : Union[str, Any] , _A : bytes ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[Any] = data ...
74
from math import isclose, sqrt def a__ ( snake_case , snake_case , snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[Any] = point_y / 4 / point_x __SCREAMING_SNAKE_CASE : int = 2 * normal_gradient / (1 + normal_gradient * norm...
74
1
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _snake_case = logging.getLogger(__name__) @dataclass class ...
611
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _snake_case = logging.get_logger("""transformers.models.speecht5""") def _A ( __magic_name__ , __magic_name__ , __magic_n...
611
1
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequenceC...
411
from __future__ import annotations from collections.abc import MutableSequence class _lowerCAmelCase : '''simple docstring''' def __init__( self : Optional[int] , UpperCamelCase : int , UpperCamelCase : MutableSequence[float] ): '''simple ...
411
1
import math def _lowerCAmelCase ( __lowerCAmelCase ) -> bool: """simple docstring""" assert isinstance(__lowerCAmelCase , __lowerCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
701
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class a ( __lowerCamelCase ): __lowerCAmelCase : List[str] = """Speech2TextFeatureExtractor""" __lowerCAmelCase : List[str] = """S...
219
0
import mpmath # for roots of unity import numpy as np class snake_case__ : '''simple docstring''' def __init__( self , a__=None , a__=None ) -> List[Any]: '''simple docstring''' __snake_case...
455
def UpperCamelCase ( snake_case__ : float ,snake_case__ : int ): '''simple docstring''' if digit_amount > 0: return round(number - int(snake_case__ ) ,snake_case__ ) return number - int(snake_case__ ) if __name__ == "__main__": ...
455
1
"""simple docstring""" def _snake_case ( UpperCamelCase : int = 50 ): UpperCAmelCase : Optional[Any] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_length ): ways_number...
717
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. A: Union[str, Any] = 2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of ...
359
0
import math def _lowercase ( lowercase__ , lowercase__ ): __lowerCAmelCase : Any = len(lowercase__ ) __lowerCAmelCase : Any = int(math.floor(math.sqrt(lowercase__ ) ) ) __lowerCAmelCase : List[Any] = 0 while arr[min(lowercase__ , lowercase...
492
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mode...
492
1
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is...
224
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput ...
224
1
from math import sqrt def _A ( SCREAMING_SNAKE_CASE__ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return F...
658
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __snake_case = logging.get_logger(__name__) __snake_case = { """microsoft/focalnet-tiny""": """https://hugg...
658
1
from __future__ import annotations import math def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multipl...
601
from typing import Any class __lowerCamelCase : """simple docstring""" def __init__( self , UpperCAmelCase ) -> List[str]: '''simple docstring''' lowercase_ = data lowercase_ = None class __lowerCamelCase ...
601
1
'''simple docstring''' import requests lowercase_ = "YOUR API KEY" def lowerCAmelCase (__A , __A = giphy_api_key): """simple docstring""" _a = '''+'''.join(query.split()) _a = F'''https://api.giphy.com/v1/gifs/search?q={formatted_query}&...
11
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, ) SCREAMING_SNAKE_CASE_ : str = { '''...
375
0
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": __UpperCAmelCase = pd.read_csv('sample_data.csv'...
713
"""simple docstring""" from ...configuration_utils import PretrainedConfig class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :Tuple = "bert-generation" def __init__( self , __A=5_0358 , __A=1024 , __A=24 , __A=16 , ...
256
0
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __lowerCAmelCase ( _A ): """simple docstring""" _lowercase , _lowercase = analyze_text(lowerCAmelCase_ ) _lowercase = lis...
398
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { """configuration_pegasus_x""": ["""PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PegasusXConfig"""], } try: if not is_torch_available(): raise OptionalDependen...
377
0
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position snake_case__ : Union[str, Any] = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.pars...
703
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def __lowerCamelCase ( A__ : int ) -> int: lowerCamelCase_ : Union[str, Any] = prime_factors(A__ ) if is_square_free(A__ ): return -1 if len(A__ ) % 2 else 1 retur...
171
0
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __lowerCAmelCase : Tuple = False class a_ ( uni...
644
"""simple docstring""" from __future__ import annotations from typing import Any class a_ : def __init__( self : Union[str, Any] , snake_case__ : int = 6 ): lowerCAmelCase__ = None lowerCAmelCase__ = None self.create_linked_list(snake_case__ ) def ...
644
1
import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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, pre...
590
def SCREAMING_SNAKE_CASE_ ( ) -> Tuple: """simple docstring""" UpperCamelCase :List[str] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] UpperCamelCase :Optional[Any] = 6 UpperCamelCase :Optional[int] = 1 UpperCamelCase :Union[str, Any] = 1901 Upper...
590
1
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_...
239
def _SCREAMING_SNAKE_CASE ( a ) -> list: if len(a ) <= 1: return lst __A : Any = 1 while i < len(a ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A : str = lst[i]...
239
1
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils...
703
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class lowercase ( tf.keras.layers.Layer ): '''simple docstring''' def __init__( self : Union[str, Any] , __lowerCamelCase : str , __lowerCamelCase : in...
187
0
import copy import re class UpperCAmelCase_ : __lowerCamelCase = 'hp' __lowerCamelCase = {} __lowerCamelCase = None @classmethod def __UpperCAmelCase ( cls , _lowerCAmelCase , _lowerCAmelCase ): ...
79
'''simple docstring''' import os from datetime import datetime as dt from github import Github lowercase_ = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ] ...
314
0
"""simple docstring""" from __future__ import annotations import math def A__ ( _UpperCAmelCase : list , _UpperCAmelCase : list ) -> list: '''simple docstring''' if len(_UpperCAmelCase ) != 2 or len(a[0] ) != 2 or len(_UpperCAmelCase ) != 2 or len(b[0] ) != 2:...
712
"""simple docstring""" import math import unittest def A__ ( _UpperCAmelCase : int ) -> bool: '''simple docstring''' assert isinstance(_UpperCAmelCase , _UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3...
150
0
"""simple docstring""" import re def _snake_case ( _snake_case : str ) -> str: '''simple docstring''' if len(re.findall('[ATCG]' , _snake_case ) ) != len(_snake_case ): raise ValueError('Invalid Strand' ) return dna.translate(dn...
7
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 lowercase__ ( __SCREAMING_SNAKE_CASE ):...
475
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_:Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:Optional[int] = { """google/switch-base-8""": """https://huggingface.co/google/switch-base-8/blob/main/config.json""", } class SCREAMIN...
701
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase = None , _lowerCAmelCase = None , _lowerCAmelCase = False , ) -> tuple[int, float, str]: """simple docstring""" A : str = cipher_alphabet or [chr(_lowerCAmelCase ) fo...
520
0
import os from typing import Dict, List, Tuple, TypeVar, Union SCREAMING_SNAKE_CASE :Optional[Any] = TypeVar('T') SCREAMING_SNAKE_CASE :Dict = Union[List[T], Tuple[T, ...]] SCREAMING_SNAKE_CASE :Optional[Any] = Union[T, List[T], Dict[str, T]] SCREAMING_SNAKE_CASE ...
55
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokeniz...
435
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
650
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseScheduler, DPM...
650
1
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _a (...
23
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness _lowerCAmelCase : List[Any] = '\\n@misc{chen2021evaluating,\n title...
246
0
"""simple docstring""" 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 comm...
85
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import Scheduler...
85
1
# Function to print upper half of diamond (pyramid) def _snake_case (__lowercase): for i in range(0 , __lowercase): for _ in range(0 , n - i - 1): # printing spaces print(' ' , end='') for _ in range(0 , i + 1): # printing stars ...
23
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Flax...
343
0
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, loggin...
710
'''simple docstring''' from __future__ import annotations A = '#' class __snake_case : def __init__( self ): """simple docstring""" lowerCamelCase : dict = {} def UpperCAmelCase_ ( self, A ): ...
449
0
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...
15
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : list[int] ): '''simple docstring''' if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) A: Tuple = sum(lowerCamelCase__ ) / len(l...
135
0
'''simple docstring''' import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor lowerCAmelCase__ = logging.getLogger(__name__) lowerCAmelCase_...
711
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = {'''vocab...
624
0
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn f...
87
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.laye...
562
0
import math def _UpperCAmelCase ( a : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return Fal...
721
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ = { """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AutoformerConfig""", ], } t...
99
0
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, ...
650
"""simple docstring""" import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () A_ : int =np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership f...
650
1
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class snake_case ( unittest.TestCase ): """simple docstring""" def snake_case__ ( self ): debug_launcher(test_script.main ) ...
715
def __lowercase ( ) -> List[Any]: '''simple docstring''' __lowercase = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] __lowercase = 6 __lowercase = 1 __lowercase = 1_901 __lowercase = 0 while year < 2_001: day += 7 if (year % 4 == 0 and year % 100 ...
576
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __SCREAMING_SNAKE_CASE (metaclass=lowerCamelCase_ ): """simple docstring""" __a =["""keras_nlp"""] def __init__( self : List[Any] , *__a : Tuple , **__a : int )...
692
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from...
350
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _A = { """configuration_efficientformer""": [ """EFFICIENTFORMER_PRETRAINED_CONFIG_...
507
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
507
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json''' ), # See all TrOCR mode...
431
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Confi...
431
1
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''vocab_file''': '''vocab.json''', '''tokenizer_config_file''': '''tokenizer_...
706
import math lowerCAmelCase__ = 1_0 lowerCAmelCase__ = 7 lowerCAmelCase__ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: int = 2_0 ) -> str: '''simple docstring''' A__ = math.comb(SCREAMING_SNAKE_CASE_ , SCREAMING...
626
0
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers i...
77
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) A = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP""", ""...
77
1
def lowerCamelCase_ ( UpperCamelCase__ : int ): '''simple docstring''' UpperCamelCase__ = [1] UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = 0, 0, 0 UpperCamelCase__ = ugly_nums[ia] * 2 UpperCamelCase__ = ...
713
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def lowerCamelCase_ ( UpperCamelCase__ : Any ): '''s...
591
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = {} class snake_case__ ( __snake_case ): _SCREAMING_SNAKE_CASE : Tuple = """llama""" ...
666
"""simple docstring""" def a__ ( __SCREAMING_SNAKE_CASE ) -> int: if n == 1 or not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): return 0 elif n == 2: return 1 else: __lowerCAmelCase: Tuple = [0, 1] for i in ra...
346
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class lowerCAmelCase : """simple docstring""" def __init__( self ) -> int: '''simple docstring''' lowerCamelCase_ ...
66
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowercase : Tuple = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Squ...
66
1
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ )-> int: """simple docstring""" def count_of_possible_combinations(SCREAMING_SNAKE_CASE_ ) -> int: if target < 0: return 0 if target == ...
628
SCREAMING_SNAKE_CASE :Dict = [ 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, ] SCREA...
628
1
"""simple docstring""" from __future__ import annotations class snake_case_: def __init__( self : int , UpperCamelCase_ : str , UpperCamelCase_ : str ): lowerCAmelCase, lowerCAmelCase : List[str] = text, pattern lowerCAmelCas...
637
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeli...
637
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrajectoryTransformer...
143
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import r...
356
0
import re import string import numpy as np import datasets lowerCamelCase : Any = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' lowerCamelCase : Optional[Any] = '\nArgs:\n predict...
713
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase ) -> Tuple: # Initialise PyTorch model ...
684
0
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTes...
100
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
1
from __future__ import annotations from decimal import Decimal from numpy import array def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[list[float]]: '''simple docstring''' __UpperCAmelCase : Any = Decimal # Check if the provided matrix has 2 r...
675
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acceler...
675
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Dict = logging.get_logger(__name__) lowerCAmelCase : Tuple = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json''', ...
214
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCAmelCase : Union[str, Any] = False class SCREAMING_SNAKE_CASE__ ( unittest.T...
214
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import os...
390
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class SCREAMING_SNAKE_CASE__ ( __UpperCamelCase ): def __lt__( self : Tuple , _lowerCAmelCase : Optional[int] ): ret...
390
1
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transf...
83
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort lowerCAmelCase__ = '''1''' lowerCAmelCase__ = '''0''' lowerCAmelCase__ = '''1''' lowerCAmelCase__ = ort.SessionOptions() lowerCAmelCase__ ...
83
1
import logging import os from .state import PartialState class _UpperCamelCase( logging.LoggerAdapter ): @staticmethod def __lowerCAmelCase ( SCREAMING_SNAKE_CASE__ : Tuple ): '''simple docstring''' __a : Dict = Partial...
577
def UpperCAmelCase__ ( lowerCamelCase_ : str , lowerCamelCase_ : str ): __a : Union[str, Any] = len(lowerCamelCase_ ) + 1 __a : Tuple = len(lowerCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string ...
577
1
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": ["TransfoXLC...
666
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], """configuration...
458
0
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_t...
716
'''simple docstring''' import sys import turtle def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ) -> tuple[float, float]: return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def SCREAMING_SNAKE_CASE_ (UpperCamelCase , Upper...
631
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil a_ = 100 a_ = set(range(3, NUM_PRIMES, 2)) primes.add(2) a_ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: continue ...
685
'''simple docstring''' import argparse import os import re a_ = 'src/transformers/models/auto' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ = re.compile(r'[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+OrderedDict'...
685
1
import math import sys def a__ (__lowercase :int ) -> int: if number != int(__lowercase ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value of input must not be a negative numb...
332
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to...
332
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json""", ...
174
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transfor...
174
1
from math import ceil def _a ( lowercase__ : int = 10_01 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Dict = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): SCREAMING_SNAKE_CASE__ : List[Any] = 2 * i + 1 SCREAMING_SNAKE_CASE__ ...
636
def _a ( lowercase__ : Optional[int] ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[int] = [] SCREAMING_SNAKE_CASE__ : List[Any] = set({'(', '[', '{'} ) SCREAMING_SNAKE_CASE__ : Optional[int] = set({')', ']', '}'} ) SCREAMING_SNAKE...
636
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileViTConfig', ...
43
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig',...
43
1
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( a , a , a ): if len(a ) == 0: raise ValueError('find_max() arg is an empty sequence' ) if ( left >= len(a ) or left < -len(a ) ...
427
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_att...
427
1
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __lowerCamelCase : List[Any] = HUGGINGFACE_HUB_CACHE __lowerCamelCase : Dict = "config.json" __lowerCamelCase : int = "diffusion_pytorch_model.bin" __lowerCamelCase : int = "diff...
323
'''simple docstring''' import gc import threading import time import psutil import torch class _snake_case : def __init__( self : Any ): SCREAMING_SNAKE_CASE:List[Any] = psutil.Process() SCREAMING_SNAKE_CASE:Dict = False def __Up...
143
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class UpperCAmelCase_ ( lowerCamelCase_ ): """simple docstring""" def __init__( self , *lowe...
435
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase_ = { 'configuration_roberta_prelayernorm': [ 'ROBERTA_PRELAYERNORM_PRETRAINE...
435
1
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('''.''') def lowerCAmelCase_( lowercase_ : List[str] ) -> str: _lowerCamelCase = tes...
661
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBer...
78
0
# 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 applicabl...
701
import math def snake_case (__lowercase , __lowercase ) -> float: '''simple docstring''' if ( not isinstance(__lowercase , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("power_factor must be a valid fl...
580
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Optional[int] ...
643
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVP...
643
1
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subprocess_async, get_g...
714
'''simple docstring''' def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ ) -> str: """simple docstring""" return "".join([hex(SCREAMING_SNAKE_CASE_ )[2:].zfill(2 ).upper() for byte in list(SCREAMING_SNAKE_CASE_ )] ) def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ ) ...
0
0
SCREAMING_SNAKE_CASE__ : Dict = [0, 2, 4, 6, 8] SCREAMING_SNAKE_CASE__ : Optional[Any] = [1, 3, 5, 7, 9] def _lowerCamelCase ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ) -> int: '''simple ...
79
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
639
0
'''simple docstring''' def _lowerCamelCase (__lowerCamelCase : str ) -> str: if not all(char in "01" for char in bin_string ): raise ValueError("Non-binary value was passed to the function" ) if not bin_string: raise ValueError("Empty string was passed to...
289
'''simple docstring''' import math def _lowerCamelCase (__lowerCamelCase : list , __lowerCamelCase : int = 0 , __lowerCamelCase : int = 0 ) -> list: a__ = end or len(__lowerCamelCase ) for i in range(__lowerCamelCase , __lowerCam...
289
1
"""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 imp...
522
"""simple docstring""" from __future__ import annotations lowercase__ :Dict = 'Muhammad Umer Farooq' lowercase__ :Any = 'MIT' lowercase__ :List[str] = '1.0.0' lowercase__ :str = 'Muhammad Umer Farooq' lowercase__ :List[str] ...
522
1
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransfo...
381
import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): # Const...
381
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.ima...
522
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowercase__ :List[Any] = Lock() def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase...
522
1
from __future__ import annotations def A__ ( __lowerCamelCase ): if not nums: raise ValueError('''List is empty''' ) return sum(__lowerCamelCase ) / len(__lowerCamelCase ) if __name__ == "__main__": import doctest doctest.testmod()
720
from PIL import Image def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = image.size SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ = image.load() for i in range(__lowerCamelCase ): for j in range(__lowerCamelCase ): SCREAMING_SNAKE_CASE_ = ...
597
0
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Li...
62
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from tran...
62
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) lowercase = {'''configuration_vit''': ['''VIT_PRET...
710
'''simple docstring''' import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) lowercase = logging.getLogger() ...
41
0
from __future__ import annotations def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): __magic_name__ : str =[] __magic_name__ , __magic_name__ : str =input_list[low:mid], input_list[...
21
from collections.abc import Sequence def lowerCAmelCase_ ( lowerCamelCase = None ): if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) __magic_name__ : str =nums[0] for i in range(1 , len(lowerCamelCase ) ...
21
1
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( lowerCAmelCase__): def _snake_case ( self : Dict , lowercase_ : Tuple=None , lowercase_ : int=None , lowercase_ : List[str]=None , **lowercase_ : Optional[Any]...
701
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import Te...
485
0
def _lowerCAmelCase ( __magic_name__ :str , __magic_name__ :str ): UpperCAmelCase_ = len(__magic_name__ ) UpperCAmelCase_ = len(__magic_name__ ) UpperCAmelCase_ = ( first_str_length if first_str_length > second_str_length else second_st...
121
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase_ : List[Any] = { """configuration_efficientformer""": [ """EFFICIENTFORMER_PRETRAINED_CONFIG_A...
670
from manim import * class _UpperCamelCase ( _A ): '''simple docstring''' def lowerCAmelCase__ ( self : int ): UpperCamelCase_: Dict = Rectangle(height=0.5 , width=0.5 ) UpperCamelCase_: Dict = Rectangle(height=0.46 ,...
670
1
'''simple docstring''' from __future__ import annotations A_ : Tuple = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } class __snake_case : '''simple docstring''' def ...
38
'''simple docstring''' import enum import shutil import sys __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = shutil.get_terminal_size() __SCREAMING_SNAKE_CASE = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class lowerCAmelCase__ ( enum.Enum ): """...
688
0
"""simple docstring""" 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_effect...
701
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logg...
18
0
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common impo...
291
from __future__ import annotations lowerCAmelCase : List[Any] = list[list[int]] # assigning initial values to the grid lowerCAmelCase : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0,...
511
0
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_...
16
"""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_bert import BertTokenizer _lowerCAmelCase = logging.get_logge...
16
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available SCREAMING_SNAKE_CASE__ : List[str] = { """configuration_gpt_neo""": ["""GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoConfig""", """GPTNeoOnnxC...
112
from sklearn.metrics import mean_squared_error import datasets SCREAMING_SNAKE_CASE__ : List[str] = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel...
112
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__: Tuple = { 'configuration_blenderbot': [ 'BLENDERBOT_...
212
from __future__ import annotations import math from collections.abc import Callable def UpperCamelCase__( UpperCamelCase__ : Callable[[int | float], int | float] , UpperCamelCase__ : int | float , UpperCamelCase__ : int | float , UpperCamelCase__ : int = 1_00 , )->flo...
212
1