code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def a_ ( __lowercase : Union[dict, list, tuple, torch.Tensor] ) -> List[T...
686
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transformers import AutoTok...
686
1
"""simple docstring""" import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _a ( lowercase_ ): '''simple docstring''' UpperCamelCase__ = (EulerDiscreteScheduler...
706
"""simple docstring""" def A( snake_case_ , snake_case_ ): """simple docstring""" return "\n".join( F"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_o...
120
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[int] = { 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ] } try: if not is_torch_ava...
556
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_forma...
486
0
'''simple docstring''' 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(): impo...
312
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> Optional[Any]: # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) UpperCAmelCase__ : Optional[Any] = (boundary[1] - boundary[0]) / steps UpperCAmelCase__ ...
312
1
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" UpperCAmelCase = { "en": "Machine learning is great, isn't it?", "ru": "Машинно...
333
import os def __UpperCamelCase ( ): """simple docstring""" with open(os.path.dirname(_lowerCAmelCase ) + "/grid.txt" ) as f: UpperCAmelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(_lowerCAmelCase ) for x in f.readline().split()] ) ...
333
1
import random from .binary_exp_mod import bin_exp_mod def snake_case_ ( _lowerCAmelCase : Any , _lowerCAmelCase : Dict=1000 ) -> Any: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is o...
702
'''simple docstring''' from __future__ import annotations import time import numpy as np UpperCamelCase__: Tuple = [8, 5, 9, 7] UpperCamelCase__: int = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] Uppe...
528
0
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node _A : Any = 4 _A : Tuple = 3 class _l...
427
'''simple docstring''' from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _lowercase ( UpperCAmelCase__ ): '...
427
1
import os import pytest from attr import dataclass UpperCAmelCase__ :List[str] = """us-east-1""" # defaults region @dataclass class SCREAMING_SNAKE_CASE : snake_case__ : str snake_case__ : Optional[Any] = 'arn:aws:iam::558105141721:role/sagemaker_exec...
719
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ :Optional[int] = logging.get_logger(__name__) UpperCAmelCase__ :List[Any] = { """asapp/sew-d-tiny-100k""": """https://...
483
0
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import Seque...
63
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 imp...
492
0
'''simple docstring''' import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device fro...
713
'''simple docstring''' import itertools import math def UpperCamelCase__ ( _lowercase : int ) -> 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 ...
466
0
"""simple docstring""" import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ....
19
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_swit...
188
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { '''configuration_efficientnet''': [ '''EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''EfficientNetCo...
717
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __lowerCAmelCase ( A_ : int ) -> Optional[Any]: _...
286
0
"""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_BLOC...
83
from __future__ import annotations def SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" if len(UpperCAmelCase__ ) == 0: return array _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = min(UpperCAmelCase__ ), max(UpperCAmelCase__ ...
605
0
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCAmelCase__ (snake_case__ : Any ): """simple docstring""" _snake_case : Dict = {} _snake_case : Union[str, Any...
28
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : list[int] , snake_case__ : str ): """simple docstring""" _snake_case : str = int(snake_case__ ) # Initialize Result _snake_case : str = [] # Traverse through ...
28
1
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyN...
610
"""simple docstring""" import math def __lowerCamelCase ( __UpperCamelCase ) -> int: """simple docstring""" if not isinstance(__UpperCamelCase , __UpperCamelCase ): lowerCAmelCase_ : Any = f'''Input value of [number={number}] must be an integer''' ...
610
1
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int ) -> int: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ): raise TypeError('''only integers accepted as input''' ) else: lowercase : Optional[int] =str(abs...
708
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> List[Any]: lowercase : Tuple =HfArgumentParser(__magic_name__ ) lowercase : Union[str, Any] =parser....
88
0
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): SCREAMING_SNAKE_CASE_ = yaml.safe_load( '''\ name: \"\" allow_empty: false allow_empty_...
373
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 = { """google/bigbird-roberta-base"...
67
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase : Tuple = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerConfig', ...
164
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __lowerCAmelCase : List[str] = logging.get_logger(__name__) _...
164
1
"""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''', '''BigBirdPegasu...
163
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __magic_name__ : Tuple = {'''configuration_plbart''': ['''PLBART_PRETRAINED_CONF...
280
0
from collections.abc import Callable def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> float: lowerCAmelCase__ : float = a lowerCAmelCase__ : float = b if function(SCREAMING_SNAKE_CASE_ ) == 0: # one of...
69
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A__ ( __magic_name__ ): ...
69
1
"""simple docstring""" from __future__ import annotations from typing import TypedDict class UpperCamelCase ( __SCREAMING_SNAKE_CASE ): A__ = 42 A__ = 42 def _lowerCAmelCase ( lowerCamelCase__ : str ) -> list[str]: if not isinstance(lower...
572
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def _lowerCAmelCase ( lowerCamelCase__ : Optional[int], lowerCamelCase__ : int=...
572
1
import unittest import numpy as np from transformers import BertConfig, 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(): from transformers.models.be...
720
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
582
0
'''simple docstring''' import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_M...
444
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class lowercase__ ( snake_case__ ): @staticmethod @abstractmethod def UpperCAmelCase__ ( snake_case__ : ArgumentParser ): raise NotImplementedError() @abstractm...
153
0
import functools def lowerCAmelCase ( UpperCamelCase__ : str , UpperCamelCase__ : str ): """simple docstring""" __UpperCAmelCase = len(UpperCamelCase__ ) __UpperCAmelCase = len(UpperCamelCase__ ) @functools.cache def min_distance(U...
718
'''simple docstring''' from ...configuration_utils import PretrainedConfig class A ( UpperCAmelCase ): a_ = '''bert-generation''' def __init__( self : str , __a : str=5_0_3_5_8 , __a : int=1_0_2_4 , __a ...
654
0
"""simple docstring""" import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging __lowerCAmelCase : Optional[int] =logging.get_logger(__name__) def UpperCAmelCase__ ( ...
359
"""simple docstring""" import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, s...
359
1
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo __UpperCamelCase : List[Any] = '''\ @misc{wu2016googles, title={Google\'s Neural Machine Translation System: Bridging ...
719
'''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/lic...
270
0
"""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, logging ...
657
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = { '''configuration_electra''': ['''ELECTRA_PRETRAINE...
657
1
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __magic_name__ ( nn.Module ): UpperCamelCase__ = 42 UpperCamelCase__ = 42 UpperCamelCase__ = 0.0...
705
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Any = { '''configuration_blenderbot_small''': [ ...
145
0
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def lowercase__ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str , **lowerCAmelCase__ : Optional[int] ) -> Union[str, Any]: '''simple docstri...
642
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _UpperCamelCase : Any = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Tran...
396
0
"""simple docstring""" import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def lowercase ...
706
"""simple docstring""" import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() a = logging.get_logger(__name__) def lowercase (snake_case__ : s...
529
0
from __future__ import annotations def __a ( A__ : Optional[int] , A__ : int ): SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = set(A_ ), [start] while stack: SCREAMING_SNAKE_CASE = stack.pop() explored.add(A_ ) ...
16
from __future__ import annotations def a__ ( A_, A_ ): '''simple docstring''' if b == 0: return (1, 0) ((__magic_name__) , (__magic_name__)) = extended_euclid(A_, a % b ) __magic_name__ = a // b return (y, x - k * y) def a__ ( ...
529
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=SCREAMING_SNAKE_CASE__ ): lowerCAmelCase__ : Union[str, Any] = ["sentencepiece"] def __init__( self : List[Any] , *lowerCamelC...
721
'''simple docstring''' from __future__ import annotations from math import pi def _lowerCamelCase (__lowerCamelCase : float , __lowerCamelCase : float , __lowerCamelCase : float ) -> dict[str, float]: if (inductance, frequency, reactance).co...
289
0
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __snake_case ( ...
38
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class SCREAMING_SNAKE_CASE__ : lowercase__ = 42 lowercase__ = None lowercase__ = None UpperCAmelCase : Dict =...
567
0
'''simple docstring''' def __lowercase (_lowercase ) -> int: """simple docstring""" if not isinstance(_lowercase, _lowercase ): raise TypeError("""only integers accepted as input""" ) else: __lowerCamelCase : Any = str(abs(_lo...
483
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase () -> str: """simple docstring""" __lowerCamelCase : Any = HfArgumentParser(_lowercase ) __lowerCamelCase : List[str]...
483
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable __lowerCAmelCase : Any =list[list[float | int]] def UpperCAmelCase__ ( lowerCAmelCase__ :Matrix , lowerCAmelCase__ :Matrix ) -> Matrix: '''simple do...
359
"""simple docstring""" import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _A ( lowerCAmelCase , unittest.TestCase ): ...
359
1
'''simple docstring''' import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, ...
720
'''simple docstring''' from manim import * class a__ ( a__ ): '''simple docstring''' def __SCREAMING_SNAKE_CASE ( self ) -> List[str]: lowerCAmelCase__ = Rectangle(height=0.5 , width=...
98
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INP...
491
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import logging ...
491
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings UpperCamelCase = r''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the d...
144
def _a ( lowerCamelCase__ ) -> float: return 10 - x * x def _a ( lowerCamelCase__ , lowerCamelCase__ ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(lowerCamelCase__ ) * equation(lowerCamelCase__ ...
144
1
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def a__ ( _SCREAMING_SNAKE_CASE : int ) -> Dict: """simple docstring""" def is_in_circle(_SCREAMING_SNAKE_CASE : ...
71
"""simple docstring""" import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class lowercase ( lowercase__ ,unittest.TestCase ): lowercase = DownBlockaD # noqa F40...
535
0
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from .....
720
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() UpperCamelCase : Dict = logging.get_logger(__name__) def UpperCamelCase_ ( __a , __a , ...
151
0
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xl...
256
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow...
256
1
import qiskit def lowercase_ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" snake_case__ : Optional[int] =qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register snake_case__ : ...
408
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class _lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def UpperCA...
408
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_time_series_transformer''': [ '''TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimeSeriesTransformerCo...
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer lowercase__ :Optional[i...
522
0
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
715
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import...
143
0
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES A: Union[str, Any] = logging.get_logger(__name__) A: List[Any] ...
160
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available snake_case__ : int = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ASTCon...
408
0
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : str , lowercase_ : str ): def get_matched_characters(lowercase_ : str , lowercase_ : str ) -> str: lowercase = [] lowercase = min(len(_stra...
706
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf lowercase_ : Union[str, An...
653
0
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging lowercase_ = logging.get_logger(__name__) def __lowerCAmelCase ( S...
413
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from ...
413
1
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np lowerCAmelCase = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 lowerCAmelCase = typing.Union[np.floataa, int, float] # noqa:...
701
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICE...
551
0
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _a : Optional[Any] = datasets.utils.logging.get_logger(__name__) class UpperCamelCase_ ( folder_based_builder.FolderBasedBuil...
479
'''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 n...
597
0
"""simple docstring""" from functools import reduce _A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950...
228
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from ...
228
1
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken loggi...
321
def __lowercase ( _UpperCAmelCase , _UpperCAmelCase ) -> List[Any]: '''simple docstring''' __lowercase = (boundary[1] - boundary[0]) / steps __lowercase = boundary[0] __lowercase = boundary[1] __lowercase = make_points(_UpperCAmelCase , _UpperCAmelCase ...
321
1
import os import re import shutil import sys import tempfile import unittest import black lowerCamelCase_ = 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_copies # noqa: E402 # This is the ...
717
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import StableDiff...
86
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer __a = logging.get_logger(__name__) __a ...
30
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = {'''vocab_file''': '''sen...
167
0
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGener...
535
def SCREAMING_SNAKE_CASE__ ( snake_case__ :List[str] ) -> Dict: _lowercase = len(snake_case__ ) while cur > 1: # Find the maximum number in arr _lowercase = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi _lowercase = a...
535
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, WavaVecaFeature...
254
"""simple docstring""" import warnings 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 UpperCAmelCase = logging.get_logger(__name__) UpperCAm...
535
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import B...
703
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from t...
399
0
'''simple docstring''' from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer lowerCAmelCase : List[str] = logging.get_logger(__name__) lowerCAmelCase : ...
3
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _snake_case (__lowercase , __lowercase , __lowercase): #...
23
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __SCREAMING_SNAKE_CASE = r'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to co...
395
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tok...
395
1
def SCREAMING_SNAKE_CASE_ ( _snake_case :int ) -> list: _A = int(_snake_case ) if n_element < 1: _A = ValueError('''a should be a positive number''' ) raise my_error _A = [1] _A , _A , _A = (0, 0, 0) _A ...
2
'''simple docstring''' import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils imp...
135
0
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , ...
710
"""simple docstring""" def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=False ): """simple docstring""" if isinstance(_UpperCAmelCase , _UpperCAmelCase ) and isinstance(_UpperCAmelCase , _UpperCAmelCase ): A_ :...
302
0
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from tra...
277
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, Be...
277
1
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from t...
399
'''simple docstring''' from collections import deque from .hash_table import HashTable class A ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __init__(self , *_UpperCAmelCase , **_UpperCAmelCase ) -> List[str]: su...
399
1
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowercase__ ( lowercase_ ) -> List[str]: """simple docstring""" if ( (cp >= 0X4e00...
624
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : int = logging.get_logger(__name__) lowerCAmelCase_ : Optional[Any] = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/mai...
716
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ : List[str] = { '''configuration_layoutlmv2''': ['''L...
156
0
"""simple docstring""" def lowercase_ ( _snake_case = 10 ,_snake_case = 1_000 ,_snake_case = True ): assert ( isinstance(UpperCAmelCase_ ,UpperCAmelCase_ ) and isinstance(UpperCAmelCase_ ,UpperCAmelCase_ ) and isinstance(UpperCAmelCase_ ,UpperCAmelCase_...
223
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def __lowerCamelCase ( UpperCAmelCase_ : int = 8 ): """simple docstring""" a :Optional[int] = ascii_letters + digits + punctuation ...
445
0
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_PARAMS, UNCONDITIONAL_IMAG...
469
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 __magic_name__ =logging.get_logger(__name__) __magic_name__ =...
469
1
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : ...
493
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def _lowerCAmelCase ( lowerCamelCase__ : Optional[int], lowerCamelCase__ : int=...
572
0
def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ = 0 ): lowercase = length or len(lowerCAmelCase__ ) lowercase = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: lowercase , lowercase = list_data[i + ...
721
class A_ : def __init__( self : Optional[Any] , snake_case__ : Dict , snake_case__ : Union[str, Any] ): lowercase = name lowercase = val def __str__( self : str ): return F"""{self...
72
0
'''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 AutoFeatureExtractor, WavaVecaFeatureExtractor from tr...
28
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
48
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { "caidas/swin2sr-classicalsr-x2-64": ( "https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/c...
621
"""simple docstring""" class snake_case : def __init__( self : Optional[int] , a__ : List[Any] , a__ : List[str] , a__ : Tuple ) -> Optional[Any]: '''simple docstring''' _A ...
621
1
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __lowerCAmelCase = logging.getLogger(__name__) class _lowerCAmelCase ( __snake_case ): '''sim...
585
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, ...
585
1
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _SCREAMING_SNAKE_CAS...
721
"""simple docstring""" import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_devi...
239
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : List[str] = logging.get_logger(__name__) __lowercase : Optional[Any] = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolv...
36
import os import pytest from attr import dataclass __lowercase : Optional[int] = '''us-east-1''' # defaults region @dataclass class _A : '''simple docstring''' __lowerCamelCase : str __lowerCamelCase : Dict = '''arn:aws:iam::558105141721:role/sagemaker...
36
1
'''simple docstring''' def snake_case_ ( a__ : int ): """simple docstring""" if upper_limit < 0: raise ValueError("""Limit for the Catalan sequence must be ≥ 0""" ) __lowercase = [0] * (upper_limit + 1) # Base case: C(0) = C(1)...
163
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin fro...
163
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config...
467
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase_ = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertConfig', 'SqueezeBertOnnxConfig...
562
0
UpperCamelCase_ = [ [0, 1_6, 1_3, 0, 0, 0], [0, 0, 1_0, 1_2, 0, 0], [0, 4, 0, 0, 1_4, 0], [0, 0, 9, 0, 0, 2_0], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _UpperCAmelCase ( UpperCamelCase: str , UpperCamelCase: Optional[Any] , UpperCamelCase: int , ...
376
from __future__ import annotations from math import ceil, floor, sqrt def _UpperCAmelCase ( UpperCamelCase: int = 2_0_0_0_0_0_0 ): """simple docstring""" __lowerCAmelCase = [0] __lowerCAmelCase = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ...
376
1
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) def a_ ( __lowercase : ...
686
import random from .binary_exp_mod import bin_exp_mod def a_ ( __lowercase : int , __lowercase : Any=1_000 ) -> int: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd _snake_case = n - 1 _snake_case ...
686
1
'''simple docstring''' import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_...
631
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vis...
631
1
from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase :List[str] = logging.get_logger(__name__) lowerCamelCase :Tuple = { 'CarlCochet/trajectory-transformer-halfcheetah-medium-v2': ( 'https://huggingface.co/CarlCochet/trajectory-...
487
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature ...
487
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils ...
229
"""simple docstring""" import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availa...
229
1
'''simple docstring''' from collections.abc import Sequence def UpperCAmelCase__ ( UpperCAmelCase_ : Sequence[float] , UpperCAmelCase_ : bool = False ) -> float: if not arr: return 0 __lowerCamelCase : str = 0 if all...
13
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = { 'configuration_deberta': ['DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Debe...
665
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ={ 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json', # See all SEW...
712
from __future__ import annotations import requests def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE : Dict = f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return requests.get(__lowerCamelCase ).json() def lowerCa...
381
0
import itertools import string from collections.abc import Generator, Iterable def __SCREAMING_SNAKE_CASE ( a__ : Iterable[str] ,a__ : int ) -> Generator[tuple[str, ...], None, None]: __A : Union[str, Any] = iter(a__ ) while True: __A : Union[str, Any] =...
17
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import Au...
568
0
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__:Dict = logging.get_logger(__name__...
721
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__:List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__:Tuple = { """google/bi...
67
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin cl...
39
'''simple docstring''' import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE ( lowerCAmelCase_ , unittest.TestCase ): snak...
150
0
'''simple docstring''' A: Any = 8.314_462 # Unit - J mol-1 K-1 def _UpperCAmelCase ( a : float , a : float , a : float ) -> float: """simple docstring""" if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('Invalid inputs. E...
7
'''simple docstring''' import os from distutils.util import strtobool def _UpperCAmelCase ( a : Any , a : int ) -> Any: """simple docstring""" for e in env_keys: lowercase_ : Optional[Any] = int(os.environ.get(a , -1 ) ...
7
1
import qiskit def _lowerCAmelCase ( A__ , A__ ): lowercase__ = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register lowercase__ = qiskit.QuantumCircuit(__lowercase , __lowercase ) # Apply X (NOT) Gate to Qubits 0 & 1 ...
622
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __SCREAMING_SNAKE_CASE = logging.get_log...
357
0
"""simple docstring""" from __future__ import annotations class A__ : def __init__( self , _SCREAMING_SNAKE_CASE = 0 ): __lowerCAmelCase : List[str] = key def __lowerCamelCase ( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): assert isinstance(_SCREA...
549
"""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(...
549
1
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : list ) -> float: '''simple docstring''' UpperCAmelCase_ = 0 while len(snake_case_ ) > 1: UpperCAmelCase_ = 0 # Consider two files with minimum cost to be merged ...
78
def __lowerCAmelCase ( A_ : int , A_ : int ) -> int: return x if y == 0 else greatest_common_divisor(A_ , x % y ) def __lowerCAmelCase ( A_ : int , A_ : int ) -> int: return (x * y) // greatest_common_divisor(A_ , A_ ) d...
221
0
"""simple docstring""" import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __A : Dict = logging....
721
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __A : str = tuple[int, int] class lowerCAmelCase__ : """simple docstring""" def __init__( self : int , lowercase__ : set[int] , lowercase...
281
0
'''simple docstring''' import re def snake_case ( snake_case : str ) -> list: """simple docstring""" return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def snake_case ( snake_case : str ) -> str: """simple docstring""" lowerC...
284
'''simple docstring''' import operator def snake_case ( snake_case : list , snake_case : bool = False , snake_case : list | None = None ) -> list: """simple docstring""" lowerCAmelCase = operator.lt if reverse else operator.gt lowerCAmelCase =...
284
1
"""simple docstring""" def snake_case__ ( _lowerCamelCase, _lowerCamelCase ) ->int: """simple docstring""" while a != 0: __lowercase : List[Any] = b % a, a return b def snake_case__ ( _lowerCamelCase, _lowerCamelCase ) ->in...
719
"""simple docstring""" from collections import deque def snake_case__ ( _lowerCamelCase ) ->Dict: """simple docstring""" __lowercase : Any = len(_lowerCamelCase ) __lowercase : str = deque() __lowercase : Tuple = ...
281
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : List[Any] ={ '''configuration_table_transformer''': [ '''TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TableTransformerConfig''', ...
483
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int = 1_00_00_00 ) -> int: __snake_case = 1 __snake_case = 1 __snake_case = {1: 1} for inputa in range(2 , _UpperCAmelCase ): __snake_case = 0 __snake_case = inputa ...
69
0
"""simple docstring""" def __lowerCAmelCase ( lowercase : Union[str, Any] , lowercase : List[str] , lowercase : Tuple , lowercase : Dict ) -> Optional[Any]: """simple docstring""" snake_case : List[str] = [...
117
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.metadata as importlib_metadata __snake...
117
1
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function _lowerCAmelCase : int = 1.0_5457_1817E-34 # unit of ℏ : J * s _lowerCAmelCase : Union[str, Any] = 3E8 # unit of...
242
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowerCAmelCase : Optional[int] = { "configuration_layoutlmv3": [ ...
242
1
from collections import Counter from timeit import timeit def _SCREAMING_SNAKE_CASE ( snake_case = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(""" """ , """""" ).lower() ).values() ) < 2 def _SCREAMING_...
710
import os import string import sys a = 1 << 8 a = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, "left": 68 + ARROW_KEY_FLAG, "mod_int": 91,...
175
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer a : List[str] = logging.get_logger(__na...
63
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE : Optional[int] = { """...
197
0
'''simple docstring''' from math import factorial class snake_case : """simple docstring""" def __init__( self , UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCamelCase_ = real if isinstance(Upper...
445
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...featur...
445
1
"""simple docstring""" from cva import destroyAllWindows, imread, imshow, waitKey def _UpperCAmelCase ( __lowerCamelCase : int ) -> str: # getting number of pixels in the image _snake_case , _snake_case = img.shape[0], img.shape[1] # converting each pixel's color to its nega...
224
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedu...
224
1
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer UpperCAmelCase__ ...
710
"""simple docstring""" import random def lowerCAmelCase_ ( UpperCamelCase__ : int , UpperCamelCase__ : float , UpperCamelCase__ : bool = False ): """simple docstring""" __lowercase = {i: [] for i in range(UpperCamelCase__ )} # if probability is g...
442
0