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''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase ) class _lowercase ( lowerCAmelCase ): '''simple docstring''' UpperCAmelCase_ ...
614
'''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 import TOK...
614
1
from __future__ import annotations from collections.abc import Iterator from typing import Any class lowerCAmelCase_ : '''simple docstring''' def __init__( self , __UpperCAmelCase ): SCREAMING_SNAKE_CASE_ : Any =data SCREAMING_SNAKE_CASE_...
709
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __SCREAMING_SNAKE_CASE = {'configuration_dpt': ['DPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DPTConfig']} try: if not is_...
153
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def snake_case_ ( A_ : Callable[[int | float], int | float], A_ : int | float, A_ : int | float, A_ : int = 1_00, ): '''simple docstring''' ...
83
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_availa...
545
0
'''simple docstring''' def __lowercase ( __SCREAMING_SNAKE_CASE ) -> Dict: """simple docstring""" __a = [] __a = set({"""(""", """[""", """{"""} ) __a = set({""")""", """]""", """}"""} ) __a = {"""{""": """}""", """[""": "...
201
'''simple docstring''' import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration SCREAMING_SNAKE_CASE_ = [ # tf -> hf ('/', '.'), ('layer_', 'layers.'), ('k...
201
1
import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import DataLo...
35
from manim import * class _A ( UpperCAmelCase_ ): def a ( self : Dict ): """simple docstring""" __UpperCamelCase : Tuple = Rectangle(height=0.5 , width=0.5 ) __UpperCamelCase : Tuple = Rectangle(height=0.46 , width=0.46 ).set_str...
269
0
'''simple docstring''' 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 impo...
700
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def a_ ( _UpperCAmelCase : Optional[Any] ,_UpperCAmelCase : int ,_UpperC...
124
0
from typing import Any def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , ): _validation( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmel...
73
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 UpperCamelCase = logging.get_logger(__name__) class _a ( lowerCAmelCase__ ): '''simple docstring''' ...
520
0
"""simple docstring""" def a__ ( snake_case__ ) -> int: if not isinstance(snake_case__ , snake_case__ ) or number < 0: raise ValueError("""Input must be a non-negative integer""" ) lowerCamelCase = 0 while number: # This way we arrive at...
533
"""simple docstring""" import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaV...
533
1
"""simple docstring""" from collections import Counter from timeit import timeit def __UpperCAmelCase ( __lowerCamelCase = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def __UpperCAmel...
560
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __A : '''simple docstring''' lowerCAmelCase : int lowerCAmelCase : TreeNode | None = ...
560
1
from itertools import count def a__ ( _UpperCamelCase : int = 50 ): __lowerCamelCase = [1] * min_block_length for n in count(_UpperCamelCase ): fill_count_functions.append(1 ) for block_length in range(_UpperCamelCase ,n + 1 ): for bloc...
622
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
622
1
'''simple docstring''' import argparse import os import re UpperCAmelCase_ : List[str] = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict UpperCAmelCase_ : Tuple = re....
24
from __future__ import annotations from typing import Any class A( UpperCamelCase ): '''simple docstring''' pass class A: '''simple docstring''' def __init__( self : List[str] , A_ : Any ) -> None: ""...
70
0
"""simple docstring""" 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 _lowercase = logging.getLogger(__name__) ...
22
"""simple docstring""" # 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 ...
22
1
import glob import os import random from string import ascii_lowercase, digits import cva SCREAMING_SNAKE_CASE : Optional[Any] = "" SCREAMING_SNAKE_CASE : Tuple = "" SCREAMING_SNAKE_CASE : str = "" SCREAMING_SNAKE_CASE : Optional[Any] = 1 # (0...
141
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''bert-base-uncased''': '''htt...
1
0
'''simple docstring''' from __future__ import annotations __UpperCAmelCase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] __UpperCAmelCase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def _snake_case ( A ) -> li...
98
'''simple docstring''' def _snake_case ( A , A ) -> bool: lowerCAmelCase__ = len(A ) + 1 lowerCAmelCase__ = len(A ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with pr...
98
1
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) __lowerCAmelCase = logging.getLogger() def _lowercase ( a__ : int ) ...
147
from manim import * class _UpperCAmelCase ( A__ ): def snake_case_ ( self): A__ = Rectangle(height=0.5 , width=0.5) A__ = Rectangle(height=0.2_5 , width=0.2_5) A__ = Rectangle(height=0.4_6 , width=0.4_6).set_...
632
0
print((lambda quine: quine % quine)('print((lambda quine: quine %% quine)(%r))'))
421
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _snake_case : Tuple = logging.get_logger(__name__) _snake_case : Any = { 'nielsr/canine-s': 2048, } # Unicode defines 1,114,112 t...
421
1
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 UpperCamelCase ( __magic_name__ : Optional[int] , __magic_name...
15
import argparse import json from tqdm import tqdm def lowerCamelCase ( ): '''simple docstring''' __UpperCamelCase :List[str] = argparse.ArgumentParser() # Required parameters parser.add_argument( '''--src_path''' , type=SCREAMING_SNAKE_CASE , default=''...
167
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import M...
353
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def A_ ( a , a , a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : int = TaConfig.from...
353
1
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A__ ( lowercase: Union[str, Any], lowercase: List[Any], lowercase: List[Any], lowerca...
305
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch _lowercase ...
305
1
"""simple docstring""" def __A ( a_ :int , a_ :int) -> int: return int((input_a, input_a).count(1) != 0) def __A ( ) -> None: assert or_gate(0 , 0) == 0 assert or_gate(0 , 1) == 1 assert or_gate(1 , 0) ==...
101
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants A = 300 # TEMPERATURE (unit = K) def __A ( a_ :float , a_ :float , a_ :float , ) -> float: if donor_conc <= 0: ...
101
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class __lowercase ( metaclass=__lowerCamelCase ): snake_case_ = ["""onnx"""] def __init__( self : int ,*A : List[str] ,**A : int ): ...
65
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging A : Optional[int] = logging.get_logger(__na...
128
0
"""simple docstring""" import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def lowercase__ ( snake_case_ :Dict , snake_case_ :str , snake_ca...
715
"""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...
397
0
"""simple docstring""" 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, re...
434
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from trans...
707
__a : Union[str, Any] = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> int: lowercase__ : List[Any] = 0 while number: # Increased Speed Slightly by checkin...
298
0
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class _UpperCAmelCase : '''simple docstring''' a__ =field(...
506
"""simple docstring""" from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class lowerCAmelCase_ ( _lowercase ): '''simple docstring''' def __init__( self : ...
91
0
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __magic_name__ = get_tests_dir("fixtures/spiece....
391
def _lowerCAmelCase ( A__: float , A__: float , A__: int ): '''simple docstring''' if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Exception('''Rate of interest must be >= 0''' ) if years_to_r...
391
1
'''simple docstring''' import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class lowercase__ ...
533
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, r...
533
1
"""simple docstring""" import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..util...
128
"""simple docstring""" import os def _lowerCamelCase ( lowerCamelCase__ : str = "matrix.txt" ): with open(os.path.join(os.path.dirname(lowerCamelCase__ ) , lowerCamelCase__ ) ) as in_file: lowercase__ : Optional[Any] = in_file.read() lowercase__ : ...
128
1
def __snake_case ( _UpperCamelCase ) -> list: if n_term == "": return [] _a = [] for temp in range(int(_UpperCamelCase ) ): series.append(f"1/{temp + 1}" if series else '''1''' ) return series if __name__ == "__main__": lowerCamelCase :Any = input('Enter t...
487
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __snake_case ( ) -> Any: _a , _a = 9, 14 # noqa: F841 _a = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [...
487
1
'''simple docstring''' 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_f...
347
'''simple docstring''' def a_ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) snake_case: Optional[Any] =str(bin...
347
1
'''simple docstring''' def snake_case_ (UpperCamelCase : int ): '''simple docstring''' if num <= 0: raise ValueError('''Input must be a positive integer''' ) _a = [True] * (num + 1) _a = 2 wh...
22
'''simple docstring''' from math import pi, sqrt def snake_case_ (UpperCamelCase : float ): '''simple docstring''' if num <= 0: raise ValueError('''math domain error''' ) if num > 171.5: raise OverflowError('''math rang...
22
1
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( lowerCamelCase__ : list[float], lowerCamelCase__ : Tuple ) -> Any: print(f'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(lowerCamelCase__ ): ...
705
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files", [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "...
295
0
"""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.conversational imp...
142
"""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 __lowercase : List[str] = logging.getLogger(__name__) __l...
142
1
from __future__ import annotations lowerCamelCase_ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] lowerCamelCase_ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def UpperCAmelCase_ ( __UpperCamelCase ): SCREAMING_SNAKE_CASE__ =[] SC...
717
import functools def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase ): SCREAMING_SNAKE_CASE__ =len(__UpperCamelCase ) SCREAMING_SNAKE_CASE__ =len(__UpperCamelCase ) @functools.cache def min_distance(__UpperCamelCase, __UpperCamelCase ) -> int...
588
0
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 _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : Tup...
641
_lowercase : Dict = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batche...
641
1
'''simple docstring''' import os import sys import unittest __snake_case : str = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, cre...
713
'''simple docstring''' __snake_case : List[Any] = 256 # Modulus to hash a string __snake_case : str = 1_000_003 def _UpperCAmelCase ( _UpperCamelCase : str, _UpperCamelCase : str ) -> bool: A_ = len(_UpperCamelCase ) ...
174
0
"""simple docstring""" import cva import numpy as np class UpperCamelCase_ : def __init__( self : Tuple , lowerCAmelCase_ : Dict , lowerCAmelCase_ : Tuple ) -> Optional[Any]: if k in (0.0_4, 0.0_6): UpperCAmelCase_ : Any =...
95
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logging ...
511
0
__A = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", """flax""": """flax>=0.4.1""", """hf-doc-builder""": """hf-doc...
716
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin cl...
173
0
'''simple docstring''' import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class A : snake_case__ :Dict = None def __SCREAMING_SNAKE_CASE ( self : Optional[Any] ): """simple docstring""" lowerCAmelCase_...
48
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppTokenize...
322
0
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class a_ ( _UpperCAmelCase ): a : List[Any] = (DDPMScheduler,) def _snake_case ( self : List[str] , **__UpperCamelCase : ...
19
"""simple docstring""" import colorsys from PIL import Image # type: ignore def _UpperCamelCase ( _A , _A , _A ) -> float: """simple docstring""" _UpperCAmelCase = x _UpperCAmelCase = y for step in range(_A ): # noqa: B007 ...
19
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers ...
657
import numpy as np def __lowerCAmelCase ( __snake_case , __snake_case , __snake_case = 1E-12 , __snake_case = 100 , ): assert np.shape(__snake_case )[0] == np.shape(__snake_case )[1] # Ensure proper dimensionality. assert np.shape(__snake_ca...
367
0
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 transformers import BartForConditionalGeneration, BartTokeniz...
639
def A ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> int: '''simple docstring''' while second != 0: _UpperCAmelCase = first & second first ^= second _UpperCAmelCase = c << 1 return first if __name__ == "__main__...
639
1
import sys def lowerCAmelCase_ (lowercase__ : List[Any] ) -> Optional[Any]: '''simple docstring''' lowerCAmelCase__ = len(lowercase__ ) lowerCAmelCase__ = [[0 for x in range(lowercase__ )] for x in range(lowercase__ )] ...
668
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Optional[int] = logging.get_logger(__name__) _UpperCAmelCase : str = { "vocab_file": "vocab.json"...
668
1
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unle...
87
"""simple docstring""" from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class _UpperCAmelCase ( _snake_case): __lowercase : int = """EncodecFeatureExtractor""" __lowercase : str = ("""T5To...
87
1
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase =g...
285
import math import unittest from transformers import BioGptConfig, 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 ModelTest...
285
1
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hug...
319
'''simple docstring''' from __future__ import annotations import time import numpy as np __lowerCAmelCase = [8, 5, 9, 7] __lowerCAmelCase = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] __lowerCAmelCase = [ [3, 2, 1, 4], ...
319
1
class _A : def __init__( self : Any ): """simple docstring""" __UpperCamelCase : Any = 0 __UpperCamelCase : int = 0 __UpperCamelCase : Optional[int] = {} def a ( self : Tuple , lowerCamelCase__ : int ): """s...
269
import os import pytest from transformers.dynamic_module_utils import get_imports UpperCamelCase = '\nimport os\n' UpperCamelCase = '\ndef foo():\n import os\n return False\n' UpperCamelCase = '\ndef foo():\n def bar():\n if True:\n im...
269
1
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and ...
207
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = { """configuration_informer""": [ """INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InformerConfig""", ], } t...
207
1
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig f...
47
from ..utils import DummyObject, requires_backends class _UpperCamelCase( metaclass=__lowerCamelCase ): __SCREAMING_SNAKE_CASE : Optional[Any] = ['''torch''', '''transformers''', '''onnx'''] def __init__( self : Dict , *SCREAMING_SNAKE_CAS...
47
1
import string from math import logaa def _snake_case ( _snake_case : List[Any] , _snake_case : List[Any] ) -> int: '''simple docstring''' _A = document.translate( str.maketrans('' , '' , ...
708
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': ( '''https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/conf...
505
0
'''simple docstring''' def A_ ( _lowerCAmelCase : int = 50 ): """simple docstring""" _lowerCamelCase : Optional[int] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ):...
44
def _lowerCAmelCase ( _lowerCAmelCase = 100 ) -> int: '''simple docstring''' __snake_case = n * (n + 1) * (2 * n + 1) / 6 __snake_case = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__"...
371
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a ={ "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_availabl...
703
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer a =logging.get_logger(__name__) a ={'voca...
132
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingfac...
365
def __snake_case ( _lowerCAmelCase : int ) -> bool: if num < 0: return False A_ : int = num A_ : int = 0 while num > 0: A_ : str = rev_num * 10 + (num % 10) num //= 10 return num_copy == r...
454
0
'''simple docstring''' import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class lowerCAmelCase_ ( __magic_name__ ): def __init__( self ...
489
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumer...
489
1
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, A...
171
# 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 considered # since ...
171
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, ...
209
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType SCREAMING_SNAKE_CASE ...
209
1
'''simple docstring''' from __future__ import annotations def snake_case_ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): '''simple docstring''' _snake_case , _snake_case = set(SCREAMING_SNAKE_CASE__ ), [start] while stack: _snake_case = ...
672
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", ...
161
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common i...
708
def _lowercase ( SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" assert ( isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) and number_of_steps > 0 ), f'number_of_steps needs to be positive integer, your input {number_of_steps}' if numb...
181
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = """...
19
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCamelCase__ ( ) -> List[str]: """simple docstring""" import os as original_os from os import path as original_path ...
19
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer from .tok...
677
import qiskit def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> qiskit.result.counts.Counts: _lowercase : Union[str, Any] = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q r...
677
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ : str = {'configuration_mmbt': ['MMBTConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() excep...
195
'''simple docstring''' from __future__ import annotations import math def lowerCamelCase ( _snake_case : float ,_snake_case : int ): '''simple docstring''' lowercase__ = u for i in range(1 ,_snake_case ): lowe...
267
0
"""simple docstring""" a : int = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", "...
700
"""simple docstring""" a : List[Any] = """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""" def lowercase__(A ) ->bytes: """simple docstring""" if not isinstance(A , A ): lowercase__ ...
85
0
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _a : List[str] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that...
213
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at...
114
0
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( ...
78
"""simple docstring""" 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 .....
78
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import floa...
511
"""simple docstring""" import math from collections.abc import Callable def UpperCAmelCase ( snake_case : Callable[[float], float] , snake_case : float , snake_case : float ): _lowerCAmelCase:float = xa _lowerCAmelCase:float ...
227
0
'''simple docstring''' import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": lowercase__ : Union[str, Any] = argparse.ArgumentParser() parser.add_argument( '''--ch...
338
'''simple docstring''' def _lowerCAmelCase ( __snake_case : Union[str, Any] , __snake_case : Tuple ) -> Union[str, Any]: __A : Tuple = [0 for i in range(r + 1 )] # nc0 = 1 __A : Dict = 1 for i in range(1 , ...
338
1
'''simple docstring''' import numpy as np import qiskit def A__ ( __lowerCAmelCase : int = 8 , __lowerCAmelCase : int | None = None ): lowerCamelCase__ = np.random.default_rng(seed=__lowerCAmelCase ) # Roughly 25% of the qubits will contribute to the ...
50
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib i...
232
0
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __UpperCAmelCase ( unittest.TestCase ): @require_torch def _a (...
714
"""simple docstring""" 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_simp...
132
0
'''simple docstring''' import numpy as np def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 1E-12 , SCREAMING_SNAKE_CASE__ = 100 , ): assert np.shape(SCREAMING_SNAKE_CASE__ )[0] == np.shape(SCREAMI...
597
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class lowerCAmelCase ( lowerCamelCase__ ): """simple docstring""" def __magic...
597
1
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_availabl...
217
"""simple docstring""" from math import ceil def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->int: a__: List[Any] = list(range(0 , _SCREAMING_SNAKE_CASE ) ) a__: Dict = [item for sublist in list(device_map.values() ) for item in sublist] # ...
217
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : int = { 's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json', } class low...
670
from cva import destroyAllWindows, imread, imshow, waitKey def snake_case (__lowercase ) -> Tuple: '''simple docstring''' _snake_case ,_snake_case : int = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(__lowercase ): ...
670
1
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
709
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __A(lowerCAmelCase ) -> List[str]: """simple docstring""" if "model" in orig_key: _UpperCamelCase = orig_key.replace("""model.""" , """""" ) if "norm1" in orig_key: _UpperCamelCase ...
202
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor lowerCamelCase :str = logging.get_logger(__name__) class _lowerCAmelCase ( __UpperCAmelCase ): def __init__(self , *lowercase , **lowercas...
667
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput cla...
667
1
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lice...
711
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging ...
446
0
'''simple docstring''' 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 ImageProcessingSavin...
41
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from trans...
41
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class A_ ( __UpperCamelCase ): '''simple docstring''' __snake_case = """Speech2TextFeatureExtractor""" __snake_case = """Speech2TextTokenizer""" def ...
706
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {'configuration_opt': ['OPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'OPTConfig']} try: ...
230
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARA...
474
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchma...
251
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class lowerCamelCase ( SCREAMING_SNAKE_CASE ): UpperCAmelCase : str = field(def...
713
from __future__ import annotations import numpy as np def lowerCamelCase_ ( UpperCamelCase_ ): return np.maximum(0 , UpperCamelCase_ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
249
0
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available fr...
647
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() SCREAMING_SNAKE_CASE_ = ...
237
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __snake_case : str = logging.get_logger(__name__) class UpperCamelCase__ ( UpperCAmelCase__): '''simple docstring''' def __init__( self , *A , **A ) ...
433
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class UpperCamelCase__ ( UpperCAmelCase__): '''simple docstring...
433
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaV...
649
'''simple docstring''' import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) ...
649
1
def a_ ( ) -> int: '''simple docstring''' return [ a * b * (1_0_0_0 - a - b) for a in range(1 , 9_9_9 ) for b in range(__snake_case , 9_9_9 ) if (a * a + b * b == (1_0_0_0 - a - b) ** 2) ][0] if __name__ == "__main__": print(...
559
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 __a : Any = logging.getLogger(__name__) __a : Dict = 50 # m...
559
1
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase: def __init__( self , __a) -> None: '''simple docstring''' _UpperCamelCase = data _UpperCamelCase = None _UpperCame...
19
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib...
63
0
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__ ( UpperCamelCase_ ): '''simp...
717
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm im...
321
0
import random def A__ ( lowercase: int, lowercase: Tuple, lowercase: List[str] ) -> Tuple: A : List[str] =a[left_index] A : List[Any] =left_index + 1 for j in range(left_index + 1, lowercase ): if a[j] < pivot: ...
305
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester ...
305
1
from __future__ import annotations from math import pi def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> dict[str, float]: '''simple docstring''' if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError('''...
675
from random import shuffle import tensorflow as tf from numpy import array def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Optional[int]: '''simple docstring''' __UpperCAmelCase : Optional[Any] = int(lowercase_ ) assert noofclust...
675
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = {...
11
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCamelCase : Optional[int] = { "configuration_vision_text_dual_encoder": ["Visi...
284
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSche...
593
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase = 1000 ) -> int: '''simple docstring''' snake_case_ ,snake_case_ = 1, 1 snake_case_ = 2 while True: snake_case_ = 0 snake_case_ = fa + fa sn...
593
1
'''simple docstring''' import unittest from transformers import XLMConfig, 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 im...
44
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class UpperCAmelCase_ ( nn.Module ): '''simple docstring''' a__ = 42 a__ ...
529
0
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distr...
316
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_camembert import Ca...
316
1
import unittest from transformers import XLMConfig, 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 ModelTesterMixin, ...
73
'''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 ModelTester...
378
0
"""simple docstring""" from __future__ import annotations from typing import TypedDict class _UpperCAmelCase ( a_ ): """simple docstring""" __snake_case = 42 __snake_case = 42 def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ): if ...
721
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _U...
558
0
"""simple docstring""" 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, ...
644
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
644
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_av...
704
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, sl...
141
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCamelCase : List[str] = logging.get_logger(__name__) __lowerCamelCase : List[str] =...
297
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer __lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) _...
297
1
def A(__a: int ): if not isinstance(__a , __a ): raise TypeError("only integers accepted as input" ) else: lowerCAmelCase_ = str(abs(__a ) ) lowerCAmelCase_ = [list(__a ) for char in range(len(__a ) )] for index in range(le...
707
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap lowerCamelCase__ = '''Usage of script: script_name <size_of_canvas:int>''' lowerCamelCase__ = [0] * 1_00 + [1] * 10 random.shuffle(choice) def A(__a: int ...
226
0
'''simple docstring''' import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTo...
347
def _lowerCAmelCase ( _lowerCAmelCase = 1000 ) -> int: '''simple docstring''' __snake_case = 2**power __snake_case = str(_lowerCAmelCase ) __snake_case = list(_lowerCAmelCase ) __snake_case = 0 for i in list_...
371
0
'''simple docstring''' def __lowerCamelCase ( ) -> Optional[Any]: """simple docstring""" UpperCamelCase = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] UpperCamelCase = 6 UpperCamelCase = 1 UpperCamelCase ...
704
'''simple docstring''' 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 impor...
324
0
import math def lowercase ( ) -> None: UpperCAmelCase_: Any = input("Enter message: " ) UpperCAmelCase_: Optional[Any] = int(input(f"Enter key [2-{len(_a ) - 1}]: " ) ) UpperCAmelCase_: Any = input("Encryption/Decryption [e/d]: " ) if ...
137
import math def __SCREAMING_SNAKE_CASE ( SCREAMING_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 return False # All prim...
345
0
'''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, ) from torch.utils...
368
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __magic_name__ : Union[str, Any] = collecti...
368
1