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
def a_ ( __lowercase : int = 50 ) -> int: _snake_case = [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...
686
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 ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPool...
686
1
'''simple docstring''' from collections.abc import Callable import numpy as np def lowercase_ ( _lowercase , _lowercase , _lowercase , _lowercase , _lowercase ) -> str: '''simple docstring''' lowerCamelCase_ : Any = int(np.ceil((x_end -...
721
'''simple docstring''' import itertools import math def lowercase_ ( _lowercase ) -> bool: '''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 num...
357
0
"""simple docstring""" import math import sys def lowercase (_snake_case ) -> Optional[int]: '''simple docstring''' if number != int(_SCREAMING_SNAKE_CASE ): raise ValueError("the value of input must be a natural number" ) if number < 0: raise ValueError("the value of i...
505
'''simple docstring''' import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __UpperCamelCase ( unittest.TestCase ): A_ = JukeboxTokenizer A_ = { "artist": "Zac Brown Band", "genres": ...
476
0
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( 'split_dict' , [ SplitDict(), SplitDict({'train': SplitInfo(name='train' , num_bytes=1337 , num_examples=42 , dat...
560
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import ...
560
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase = { """configuration_poolformer""": [ """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
104
"""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 UpperCamelCase = logging.get_logger(__na...
104
1
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow,...
519
from collections.abc import Iterable from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar('''_T''') class __SCREAMING_SNAKE_CASE ( Generic[_T] ): """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE__ = None ): """simple docstring""" ...
519
1
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distribu...
73
from __future__ import annotations def lowerCamelCase__ (_UpperCAmelCase): SCREAMING_SNAKE_CASE = 2 SCREAMING_SNAKE_CASE = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(_UpperCAmelCase) if n > 1: factors....
73
1
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets UpperCamelCase__ : int = "\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n ...
720
'''simple docstring''' def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ ) -> int: """simple docstring""" if not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < ...
0
0
'''simple docstring''' import os def lowercase__ ( ): '''simple docstring''' with open(os.path.dirname(__UpperCamelCase ) + """/p022_names.txt""" ) as file: __lowercase = str(file.readlines()[0] ) __lowercase = names.replace("""\"""" , ...
566
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transfor...
566
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : str = logging.get_logger(__name__) _UpperCAmelCase : Tuple = { '''facebook/xglm-564M''': '''https://huggingface.co/facebook/xglm-564M/resolve/main/config.json''', ...
721
'''simple docstring''' from __future__ import annotations _UpperCAmelCase : str = 10 def UpperCamelCase ( lowercase_ : list[int] ) -> list[int]: '''simple docstring''' lowercase =1 lowercase =max(lowercase_ ) while placement <= max_digit: # declare...
145
0
from manim import * class _A ( UpperCAmelCase_ ): def a ( self : str ): """simple docstring""" __UpperCamelCase : Union[str, Any] = Rectangle(height=0.5 , width=0.5 ) __UpperCamelCase : List[str] = Rectangle(height=0.25 , width=0.2...
269
from collections.abc import Iterable from typing import Generic, TypeVar UpperCamelCase = TypeVar('_T') class _A ( Generic[_T] ): def __init__( self : int , lowerCamelCase__ : Iterable[_T] | None = None ): """simple docstring""" __UpperCamelCase : ...
269
1
"""simple docstring""" import math def a__ ( snake_case__ ) -> bool: 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 retu...
533
"""simple docstring""" import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowerCAmelCase : Dict = argparse.ArgumentParser() parser.add_argument( ""...
533
1
from __future__ import annotations from typing import Generic, TypeVar a : List[Any] = TypeVar('T') class _a ( Generic[T] ): def __init__(self, SCREAMING_SNAKE_CASE_ ) -> None: UpperCAmelCase_: str = data UpperCA...
556
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : Optional[Any] = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization_mvp': ['Mv...
556
1
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_d...
697
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFea...
697
1
'''simple docstring''' import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformer...
597
'''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, B...
597
1
def UpperCamelCase_( _A :str )-> str: return "".join(chr(ord(_A ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
185
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import c...
185
1
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from a...
38
'''simple docstring''' import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class A ( pl.LightningModule ): def __init__( self : Dict , __a : List[str] ...
262
0
import logging import os import threading import time try: import warnings except ImportError: _snake_case = None try: import msvcrt except ImportError: _snake_case = None try: import fcntl except ImportError: _snake_case = None # Backward compatibility # --------...
54
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class lowercase ( tf.keras.layers.Layer ): def __init__( self , _a , ...
54
1
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configura...
218
"""simple docstring""" def lowercase__(A ) ->bool: """simple docstring""" return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def lowercase__(A ) ->bool: """simple docstring""" lowerca...
218
1
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.model...
387
from __future__ import annotations def lowerCamelCase_ ( _lowercase , _lowercase , _lowercase ) -> float: if days_between_payments <= 0: raise ValueError("days_between_payments must be > 0" ) if daily_interest_rate < 0: raise ValueError("daily_interes...
387
1
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : str , UpperCAmelCase_ : str ) -> str: __lowerCamelCase : int = len(UpperCAmelCase_ ) __lowerCamelCase : int = len(UpperCAmelCase_ ) ...
13
"""simple docstring""" 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 impo...
549
0
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils impo...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a__ = { """configuration_canine""": ["""CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CanineConfig"""], """tokenization_canine""": ["""CanineTokenizer...
198
0
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get_file_...
84
'''simple docstring''' import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available f...
697
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( lowerCamelCase : dict , lowerCamelCase : str): A_ , A_ : List[Any] = set(lowerCamelCase), [start] while stack: A_ : Optional[Any] =...
27
'''simple docstring''' import unittest from transformers import 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...
27
1
"""simple docstring""" __snake_case = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) __snake_case = frozenset(['p...
200
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONF...
200
1
"""simple docstring""" import math def A__ ( _UpperCAmelCase : int ) -> int: '''simple docstring''' if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): snake_case__ : List[Any] = F"""Input value of [number={number}] must be an integer""" raise TypeError(_Up...
150
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=_lowercase): '''simple docstring''' __magic_name__ : List[str] = ['''torch'''] def __init__( self , *lowerCamelCase__ , **...
150
1
"""simple docstring""" import inspect import unittest from transformers import MobileNetVaConfig 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_confi...
82
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimensio...
666
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase = {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]} try: if not is_torch_available(): raise OptionalDependencyNot...
190
"""simple docstring""" def lowercase ( ) -> int: return 1 def lowercase ( __UpperCamelCase ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def lowercase ( __UpperCamelCase ) -> int: return 0 if x < 0 else five_pence(x - 5 )...
190
1
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from trans...
149
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case__ ( UpperCamelCase_ ): def __init__( self : int , _lowerCamel...
170
0
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxModel...
199
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _SCREAMING_SNAKE_CASE ( __lower...
199
1
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be consider...
54
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to ha...
166
0
from __future__ import annotations import os from typing import Any import requests UpperCamelCase = "https://api.github.com" # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user UpperCamelCase = BASE_URL + "/user" # https://github.c...
700
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): ...
383
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets a_ :Tuple = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification},\n authors={Xu, Wei and Napole...
478
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2), 7: (...
579
0
'''simple docstring''' import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenizat...
704
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available()...
11
0
A : Optional[Any] = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': 'ABBAA', 'o': 'ABBAB', 'p': 'AB...
219
"""simple docstring""" from __future__ import annotations from collections import deque class __A : def __init__( self , a__ ): _lowerCAmelCase : list[dict] = [] self.adlist.append( {"""value""": """""", """next_states""": [], """fail_state""": 0, "...
213
0
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __A ( a_ : Dict ,a_ : Optional[int] ,a_ : Union[str, Any] ,a_ : List[Any] ,a_ : List[Any] ):...
719
'''simple docstring''' def __A ( a_ : int ): if not isinstance(a_ ,a_ ): lowerCAmelCase : Dict = f'''Input value of [number={number}] must be an integer''' raise TypeError(a_ ) if number < 0: return False lowerCAmelCase : Dict = number...
551
0
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def A__ (snake_case : List[str] ) -> Optional[int]: __UpperCamelCase : Tuple = [ """decoder.version""...
279
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__": a__ = pd.read_csv('''sample_data.csv''', header=None) a__ = df.shape[:1...
279
1
"""simple docstring""" def lowerCamelCase ( _snake_case ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence UpperCAmelCase__ : List[Any] = gray_cod...
254
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def lowerCamelCase ( _snake_case ): return ConvertCommand( args.model_type ,args.tf_checkpoint ,args.pytorch_dump_output ,args.config ...
254
1
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversatio...
437
"""simple docstring""" def UpperCAmelCase_ ( __a : int ): '''simple docstring''' _lowerCamelCase : Optional[Any] = int(__a ) if decimal in (0, 1): # Exit cases for the recursion return str(__a ) _lowerCamelCase , _lowerCame...
437
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __UpperCamelCase ( lowerCAmelCase__ ): ...
711
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging lowercase_ = logging.get_logger(__name__) def a__ ( snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : Opt...
131
0
'''simple docstring''' from __future__ import annotations class UpperCAmelCase_ : """simple docstring""" def __init__( self : Optional[int] , snake_case_ : str , snake_case_ : str ): snake_case__ , snake_case__ : Optional[int] ...
374
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, l...
374
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
128
"""simple docstring""" import heapq def _lowerCamelCase ( lowerCamelCase__ : dict ): lowercase__ : 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 ...
128
1
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( __snake_case : int | float | str, __snake_case : int | float | str ) -> list[str]: """simple docstring""" if nth_term == "": return [""] A__ : Any =int(__s...
215
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __snake_case : List[str] = { 'configuration_trocr': ['TROCR_PRETRAINED_CONFIG_...
215
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__:Optional[Any] = {"""configuration_xlnet""": ["""XL...
701
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class snake_case__ : _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [batch_size...
67
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ...
209
'''simple docstring''' import numpy as np import qiskit def lowerCamelCase ( UpperCAmelCase__ : int = 8 , UpperCAmelCase__ : int | None = None ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE__ :Union[str, Any] = np.random.default_rng(seed=U...
209
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot...
335
from __future__ import annotations from dataclasses import dataclass @dataclass class __a : __lowercase : float __lowercase : TreeNode | None = None __lowercase : TreeNode | None = None def snake_case_ ( snake_case )...
335
1
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE ( a ): """simple docstring""" a_ : Any =["image_processor", "tokenizer"] a_ : List[str] ="AutoImag...
232
"""simple docstring""" import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging __magic_name__ = logging.get_logger(__name__)...
232
1
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def UpperCamelCase ( UpperCAmelCase ) ->list[list[float]]: """simple docstring""" a_ = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this...
210
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ) ->float: """simple docstring""" if digit_amount > 0: return round(number - int(UpperCAmelCase ) , UpperCAmelCase ) return number - int(UpperCAmelCase ) if __name__ == "__main__": ...
210
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase :Any = logging.get_logger(__name__) _lowerCAmelCase :Dict = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""",...
251
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_...
198
0
"""simple docstring""" import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sen...
720
"""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
0
import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCase ="▁" _lowerCamelCase ...
681
UpperCAmelCase : Any = [0, 2, 4, 6, 8] UpperCAmelCase : Optional[Any] = [1, 3, 5, 7, 9] def __lowerCamelCase ( lowerCamelCase__ : int , lowerCamelCase__ : int , lowerCamelCase__ : list[int] , lowerCamelCase__ : int ): '''...
457
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diff...
145
'''simple docstring''' _UpperCAmelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def UpperCamelCase ( ) -> None: '''simple docstring''' lowercase =input('''Enter message: ''' ) lowercase =input('''Enter key [alphanumeric]: ''' ) lowercase =i...
145
1
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, WavaVecaFeatureExtractor, WavaVe...
35
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCAmelCase : Tuple = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weight", "time_embedding.linear_1.weight"), ...
457
0
'''simple docstring''' from __future__ import annotations lowerCAmelCase : int = [True] * 1_00_00_01 lowerCAmelCase : int = 2 while i * i <= 1_00_00_00: if seive[i]: for j in range(i * i, 1_00_00_01, i): lowerCAmelCase : Any ...
715
'''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 ...
432
0
"""simple docstring""" import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils imp...
29
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def UpperCamelCase ( s...
455
0
"""simple docstring""" import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow lowerCamelCase__ = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ "text-c...
51
"""simple docstring""" import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_...
51
1
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : Namespace ) -> List[str]: return ConvertCommand( args.model_type , args.tf_checkpoint , ar...
443
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common...
443
1
'''simple docstring''' import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def ...
697
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset from utils import logger class SCREAMING_SNAKE_CASE__ ( __UpperCamelCase ): def __init__( self , __UpperCamelCase , __UpperCamelCase ): '''simple docst...
697
1
'''simple docstring''' from manim import * class A_ ( lowerCAmelCase_ ): def lowercase ( self : Dict ): _UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) _UpperCAmelCase = Rectangle(height=0.4_6 , width=0.4_6 ...
236
'''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 __SCREAMING_SNAKE_CASE :int = logging.getLogger(__name__) __SCR...
236
1
from __future__ import annotations from collections.abc import MutableSequence class _lowerCAmelCase : """simple docstring""" def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> None: """simple docstring""" ...
408
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attent...
408
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Optional[Any] = logging.get_logger(__name__) a_ : List[str] = {"""openai-gpt""": """https://huggingface.co/openai-gpt/resolve/main/config.json"""} class __UpperCamelCase ...
676
'''simple docstring''' def a_ ( __snake_case : int , __snake_case : int ) -> str: """simple docstring""" if not isinstance(__snake_case , __snake_case ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(__snak...
676
1
"""simple docstring""" import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class lower...
494
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transf...
494
1
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> int: if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) or number < 0: raise ValueError("""Input must be a non-negative integer""" ) __lowerCAmelCase : List[str] = 0 wh...
504
import numpy class snake_case_ : def __init__( self : List[str] , _snake_case : numpy.ndarray , _snake_case : numpy.ndarray )->None: '''simple docstring''' __lowerCAmelCase : Union[str, Any] = input_array # Random initial weights are ass...
504
1
from collections import defaultdict def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> bool: __lowerCamelCase : Optional[int] = first_str.lower().strip() __lowerCamelCase : Dict = second_str.lower().strip() # R...
337
from ..utils import DummyObject, requires_backends class A_ ( metaclass=SCREAMING_SNAKE_CASE ): _UpperCAmelCase : List[Any] = ['''sentencepiece'''] def __init__( self : Any ,*SCREAMING_SNAKE_CASE__ : List[str] ,**SCREAMING_SNAKE_CASE__ : str): ...
337
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_ = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], ...
34
"""simple docstring""" def __snake_case ( _lowercase ): """simple docstring""" UpperCamelCase = [0 for i in range(len(_lowercase ) )] # initialize interval's left pointer and right pointer UpperCamelCase , UpperCamelCase = 0, 0 ...
34
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Dict = { """configuration_x_clip""": [ """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XCLIPConfig""", """XCLIPTextConfig""", """XCLIPVi...
450
from __future__ import annotations import math def lowerCamelCase_ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if num <= 0: SCREAMING_SNAKE_CASE = f"""{num}: Invalid input, please enter a positive integer.""" raise ValueError(SCREAMING_SNAKE_CASE ) SCREAMIN...
450
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : List[str] = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab...
184
from __future__ import annotations from statistics import mean def a ( A__ : list[int] , A__ : list[int] , A__ : int ) -> list[int]: """simple docstring""" _lowercase =[0] * no_of_processes _lowercase =[0] * no_of_processes ...
291
0
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.ut...
716
"""simple docstring""" import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class lowerCA...
66
0
'''simple docstring''' from __future__ import annotations from typing import Any class lowerCAmelCase ( __lowerCAmelCase ): pass class lowerCAmelCase : def __init__( self : Any , __lowercase : List[str] ): """simple docstring""" ...
119
def snake_case ( snake_case__ :int = 1_000) -> int: _A = -1 _A = 0 for a in range(1 , n // 3): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c _A = (n * n - 2 * a * n) // (2 * n - 2 * a) _A =...
401
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is...
718
'''simple docstring''' from __future__ import annotations class _lowercase : def __init__( self , _UpperCAmelCase ): A : str = data A : Node | None = None A : Node | None = None def ...
537
0
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils ...
108
"""simple docstring""" import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _a : int = 'Usage of script: script_name <size_of_canvas:int>' _a : List[Any] = [0] * 100 + [1] * 10 random.shuffle(choice) def ...
213
0
"""simple docstring""" from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class a ( A_ ): '''simple docstring''' A_ : List[str] = '''EncodecFeatureExtractor''' ...
714
"""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 ImageProcessingSavingTestMix...
173
0
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": a__ = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str, required=True, help='''...
14
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
495
0
"""simple docstring""" 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 BatchEncoding, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.g...
370
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", ...
370
1
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _a...
168
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) ...
168
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a : Optional[Any] = { 'configuration_blip': [ 'BLIP_PRETRAINED_CONF...
710
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def SCREAMING_SNAKE_CASE ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_): a__ = OmegaConf.load(lowerCamelCase_...
200
0
import os from collections.abc import Iterator def _lowerCAmelCase ( A__ = "." ): for dir_path, dir_names, filenames in os.walk(A__ ): lowercase__ = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] for filename in filenames: if filename ==...
622
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _lowerCAmelCase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.ra...
622
1
from __future__ import annotations from functools import lru_cache from math import ceil __lowercase :Tuple = 100 __lowercase :Optional[int] = set(range(3, NUM_PRIMES, 2)) primes.add(2) __lowercase :int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes...
720
from __future__ import annotations from fractions import Fraction def UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : int ): '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num ...
26
0
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class __magic_name__ : __A : str = field( metadata={"h...
677
"""simple docstring""" def lowerCamelCase (a_ :int = 100) -> int: lowercase :Union[str, Any] = set() lowercase :List[Any] = 0 lowercase :Dict = n + 1 # maximum limit for a in range(2 , a_): for b in ...
677
1
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image f...
411
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow ...
411
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_available, is_torch_available ...
84
"""simple docstring""" from string import ascii_uppercase lowerCAmelCase__ = {str(ord(c) - 55): c for c in ascii_uppercase} def a__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if isinstance(SCREAMING...
645
0
"""simple docstring""" import argparse from collections import defaultdict import yaml __lowerCamelCase = "docs/source/en/_toctree.yml" def UpperCAmelCase ( UpperCamelCase__ ): """simple docstring""" A__ = defaultdict(_l...
717
"""simple docstring""" from manim import * class UpperCamelCase__( __A ): def snake_case__ ( self ) -> List[str]: A__ = Rectangle(height=0.5 ,width=0.5 ) A__ = Rectangle(height=0.4_6 ,width=0.4_6 ).set_stro...
536
0
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, ...
518
import glob import os import random from string import ascii_lowercase, digits import cva a = "" a = "" a = "" a = 1 # (0 is vertical, 1 is horizontal) def _SCREAMING_SNAKE_CASE ( ) -> None: _UpperCAmelCase , ...
518
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects import * ...
702
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _lowerCamelCase : def __init__( self , SCREAMING_SNAKE_CASE_ = None ): if components is None: __snake_case = ...
345
0
"""simple docstring""" def UpperCamelCase (SCREAMING_SNAKE_CASE ): UpperCamelCase : str = len(SCREAMING_SNAKE_CASE ) for _ in range(SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 , 2 ): ...
102
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distr...
424
0
"""simple docstring""" def snake_case__ ( __lowerCamelCase : str , __lowerCamelCase : str ): """simple docstring""" if not (isinstance(__lowerCamelCase , __lowerCamelCase ) and isinstance(__lowerCamelCase , __lowerCamelCase )): raise ValueError(''...
625
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowercase : Optional[Any] = { "conf...
625
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) ...
347
'''simple docstring''' 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 : Optional[Any] , snake_case_ : List[str]=2 ...
347
1
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common...
38
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def A_ ( ) -> Dict: UpperCamelCase : Tuple = ArgumentParser( description=( "PyTorch TPU distributed training laun...
38
1
'''simple docstring''' import os def UpperCAmelCase_ ( ): """simple docstring""" with open(os.path.dirname(lowerCAmelCase_ ) + "/grid.txt" ) as f: lowercase = [] # noqa: E741 for _ in range(20 ): l.append([int(lowerCAmelCase_ ) for ...
310
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import ...
310
1
'''simple docstring''' import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import f...
123
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class Upper...
123
1
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def a__ ( _UpperCamelC...
175
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __UpperCAmelCase ( __a : ...
14
0
"""simple docstring""" import math SCREAMING_SNAKE_CASE_ = 10 SCREAMING_SNAKE_CASE_ = 7 SCREAMING_SNAKE_CASE_ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__ = 20 ) -> Dict: a_ : Tuple = math.comb(_lowerCamelCase, _lowerCamelCa...
700
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretrained-embe...
370
0
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnl...
694
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attent...
694
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
716
import unittest from knapsack import greedy_knapsack as kp class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Optional[Any] ) -> Union[str, Any]: a__ = [10, 20, 30, 40, 50, 60] a__ = [2, 4, 6, 8, 10, 12] a__ = 1...
657
0
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax...
405
'''simple docstring''' 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 lowerCamelCase : Union[str, Any] = logging...
405
1
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @requir...
68
'''simple docstring''' 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 f...
68
1
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : float ) -> float: return 10 - x * x def SCREAMING_SNAKE_CASE ( __UpperCamelCase : float , __UpperCamelCase : float ) -> float: # Bolzano theory in order to find if there is a root between a and b ...
144
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Union[str, Any] ) -> Union[str, Any]: UpperCAmelCase_ , UpperCAmelCase_ = [], [] while len(__UpperCamelCase ) > 1: UpperCAmelCase_ , UpperCAmelCase_ = min(__UpperCamelCase ), max(__UpperCamelCas...
144
1
import datasets A__ = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n and Stoy...
718
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 @require_tokenizers cla...
184
0
import gc import threading import time import psutil import torch class A__: """simple docstring""" def __init__( self ) -> List[str]: a_ : Any = psutil.Process() a_ : Optional[int] = False def UpperCamelCase__ ...
540
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.util...
540
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from...
184
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _lowercase ( a_ : str ,a_ : str ,a_ : str ,a_ : Path ,a_ : str = None ,a_ : str = N...
184
1