code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import colorsys from PIL import Image # type: ignore def lowerCamelCase__ ( a__ , a__ , a__) -> float: """simple docstring""" _snake_case : Tuple = x _snake_case : List[Any] = y for step in range(lowerCAme...
517
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :int = 5_0 ) -> int: '''simple docstring''' lowercase = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , ...
359
0
'''simple docstring''' import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase ( __lowerCAmelCase , unittest.TestCase ): '''simple docstrin...
716
'''simple docstring''' import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datase...
27
0
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, ...
465
def _lowerCAmelCase ( __lowerCAmelCase = 200 ) -> int: """simple docstring""" snake_case__ : Optional[int] = [1, 2, 5, 10, 20, 50, 100, 200] snake_case__ : List[Any] = [0] * (pence + 1) snake_case__ : str = 1 # base case: 1 w...
252
0
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
504
import torch def _lowerCAmelCase (): if torch.cuda.is_available(): UpperCamelCase_ = torch.cuda.device_count() else: UpperCamelCase_ = 0 print(f"""Successfully ran on {num_gpus} GPUs""") if __name__ == "__main__": main()
504
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.mo...
438
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : Optional[int] = logging.get_logger(__name__) _lowerCAmelCase : Tuple = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve...
438
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) ...
705
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", ...
370
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ : List[str] = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxC...
589
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Any = logging.get_logger(__name__) a__ : Tuple = { """facebook/encodec_24khz""": """https...
589
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
721
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, requ...
291
0
from __future__ import annotations def __UpperCamelCase (lowerCAmelCase : list, lowerCAmelCase : int, lowerCAmelCase : int, lowerCAmelCase : int ) -> list: A = [] A , A = input_list[low:mid], input_list[mid : high + 1] while left...
699
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequenceCl...
699
1
def A_ ( _lowerCAmelCase ) -> list[int]: UpperCamelCase : Optional[int] = [0 for i in range(len(_lowerCAmelCase ) )] # initialize interval's left pointer and right pointer UpperCamelCase , UpperCamelCase : Optional[Any] = 0, 0 for i in range(1 , len...
38
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __lowerCamelCase : Dict = logging.get_logger(__name__) __lo...
38
1
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline a = logging.get_logger(__name__) @add_end_docstring...
412
def UpperCAmelCase_ ( UpperCAmelCase__ = "The quick brown fox jumps over the lazy dog" , ): lowercase_ = set() # Replace all the whitespace in our sentence lowercase_ = input_str.replace(""" """ , """""" ) for alpha in input_str: if "a" <= alph...
412
1
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if...
718
'''simple docstring''' from __future__ import annotations def snake_case_ (_a : str , _a : list[str] | None = None ): UpperCAmelCase = word_bank or [] # create a table UpperCAmelCase = len(_a ) + 1 UpperCAmelCase = [] for _ in range(_a ...
358
0
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import ...
19
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def A__ ( UpperCAmelCase_ ): if "model" in orig_key: _UpperCamelCase : List[Any] = orig_key.replace('model.' , '' ) if "norm1" in orig_key: ...
195
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor _A = logging.get_logger(__name__) class __UpperCAmelCase ( snake_case__ ): """simple docstring""" def __init__( self : Dict , ...
228
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _A = "." # Internal TensorFlow ops tha...
228
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _lowerCamelCase = logging.get_logger(__name__) class _snake_case (__SCREAMING_SNAKE_CASE): def __init__( self ,*_snake_case ,**_snak...
71
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
222
0
import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAutoModel from tran...
102
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modeling_...
102
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class __lowercase( _UpperCAmelCase ): '''simple docstring''' @staticmethod @abstractmethod def snake_case_ ( __a ): raise NotImplementedError() @abstractme...
594
'''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_learn...
421
0
'''simple docstring''' 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 _UpperCamelCase ( ...
708
'''simple docstring''' import qiskit def _A ( A ,A ) -> qiskit.result.counts.Counts: lowercase : Tuple = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register lowercase : List[Any] = qiskit.QuantumCircuit(A ...
425
0
import json import sys def UpperCamelCase ( snake_case__ : Optional[Any] , snake_case__ : Dict ) -> Dict: with open(snake_case__ , encoding='utf-8' ) as f: UpperCamelCase : Optional[Any] = json.load(snake_case__ ) UpperCamelCase ...
40
'''simple docstring''' import re def __UpperCAmelCase (lowercase__ ) -> bool: '''simple docstring''' a_ = re.compile( r"^(?:0|94|\+94|0{2}94)" r"7(0|1|2|4|5|6|7|8)" r"(-| |)" r"\d{7}$" ) return bool(re.search(lowercase__ ,lowercase__ )...
685
0
def UpperCAmelCase__ ( _A , _A = 0 ): """simple docstring""" a_ = length or len(_lowerCamelCase ) a_ = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: a_ = list_data[i + 1], list_data[i] a_ = Tru...
717
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class __lowercase ( enum.Enum ...
143
0
'''simple docstring''' import numpy # List of input, output pairs __UpperCAmelCase = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) __UpperCAmelCase = (((515, 22, 13), 555), ((61, 35, 49), 15...
90
'''simple docstring''' 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...
541
0
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class A_ ...
565
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = [[] for _ in range(__SCREAMING_SNAKE_CASE )] lowercase = key - 1 if key <= 0: raise ValueError('Height of grid can\'t be 0 or negative' ) if key == 1 or len(__SCREAM...
565
1
def a_ ( __lowercase : int = 4_000_000 ) -> List[Any]: _snake_case = [0, 1] _snake_case = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 _snake_case = 0 for j in ...
686
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch...
134
0
from bisect import bisect from itertools import accumulate def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" UpperCAmelCase = sorted(zip(_lowerCAmelCase , _lowerCAmelCase ) , key=lambda _lowe...
718
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity_info() __lowerC...
405
0
def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" if digit_amount > 0: return round(number - int(lowerCAmelCase_ ) , lowerCAmelCase_ ) return number - int(lowerCAmelCase_ ) if __name__ == "__main__": print(decimal_isolate(1.53, 0)) ...
496
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_M...
283
0
from __future__ import annotations import unittest from transformers import RoFormerConfig, 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_mask...
701
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A__ : Any = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} try: ...
671
0
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoCon...
609
"""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, get_resize_output_image_size, normalize, rescale, r...
609
1
"""simple docstring""" def lowercase (_snake_case ,_snake_case ) -> Any: '''simple docstring''' __UpperCamelCase = 0 __UpperCamelCase = len(lowerCAmelCase_ ) - 1 while left <= right: # avoid divided by 0 during interpolation if so...
707
"""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
0
from __future__ import annotations import math import random from typing import Any class __A : def __init__( self : Dict ): lowerCAmelCase : list[Any] = [] lowerCAmelCase : int = 0 lowerCAmelCase : int ...
343
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Optional[Any]: '''simple docstring''' def wrapper(*_UpperCAmelCase, **_UpperCAmelCa...
343
1
from ...configuration_utils import PretrainedConfig class A__ ( __snake_case ): '''simple docstring''' snake_case__ = """bert-generation""" def __init__( self : Dict , _SCREAMING_SNAKE_CASE : Optional[int]=5_03...
410
__magic_name__ : List[str] = tuple[float, float, float] __magic_name__ : Optional[int] = tuple[float, float, float] def lowercase__ ( _UpperCamelCase , _UpperCamelCase) -> Vectorad: """simple docstring""" UpperCamelC...
410
1
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, ...
469
def lowerCamelCase_ ( UpperCamelCase__ : str ) -> list: """simple docstring""" if n_term == "": return [] __lowerCamelCase = [] for temp in range(int(UpperCamelCase__ ) ): series.append(F"""1/{temp + 1}""" if series else '1'...
469
1
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMSch...
615
"""simple docstring""" import unittest from knapsack import knapsack as k class A__ ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE ( self: Optional[int]) -> List[Any]: """simple docstring""" ...
615
1
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class __A ( A ): '''simple docstring''' ...
11
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _a ( UpperCAmelCase ) -> Any: """simple docstring""" return getitem, k def _a ( UpperCAmelCase , UpperCAmelCase ) -> Union[s...
315
0
"""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 cl...
720
"""simple docstring""" from __future__ import annotations A_ = 10 def _lowerCAmelCase ( UpperCAmelCase__ : list[int] ) ->list[int]: A__ : Any = 1 A__ : Optional[int] = max(UpperCAmelCase__ ) while placement <= max_digit: ...
498
0
'''simple docstring''' import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowerCamelCase__ ( SCREAMING_SNAKE_CASE : Tuple , SCREAMING_SNAKE_CASE : int=7 ): UpperCAmelCase = None if token is not None: Up...
447
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class lowercase_ ( unittest.TestCase ): '''simple docstring''' ...
447
1
import math def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' snake_case_ = len(UpperCamelCase__ ) snake_case_ = int(math.floor(math.sqrt(UpperCamelCase__ ) ) ) snake_case_ ...
721
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor _UpperCAmelCase : Any = logging.get_logger(__name__) class lowercase ( lowercase_ ): def __init__( self , *snake_case , **snake_case ): ...
108
0
from __future__ import annotations from fractions import Fraction def UpperCamelCase_( _A :int , _A :int )-> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def UpperCamelCase_( _A :int )-> list[str]: UpperCamelCase__ ...
551
def UpperCamelCase_( _A :Union[str, Any] )-> List[str]: UpperCamelCase__ = [0] * len(_A ) UpperCamelCase__ = [] UpperCamelCase__ = [] UpperCamelCase__ = 0 for values in graph.values(): for i in values: indegree[i] += 1 for...
551
1
"""simple docstring""" from __future__ import annotations def A__ ( _UpperCAmelCase : list[int] , _UpperCAmelCase : list[int] , _UpperCAmelCase : int ) -> tuple[float, list[float]]: '''simple docstring''' snake_case__ : Any = list(range(len...
711
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ...
150
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _snake_case : Optional[Any] = False class a (unittest.TestCase ): """simple docstrin...
81
from __future__ import annotations from typing import Any def lowerCAmelCase_ ( __lowerCamelCase ): create_state_space_tree(__lowerCamelCase , [] , 0 ) def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase )...
81
1
import unittest from knapsack import knapsack as k class a_( unittest.TestCase ): """simple docstring""" def __UpperCamelCase ( self : str) -> str: """simple docstring""" SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = [0] ...
259
import argparse from collections import defaultdict import yaml __UpperCAmelCase = "docs/source/en/_toctree.yml" def A_ ( lowercase_ ) ->Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE = defaultdict(lowercase_ ) for doc in model_doc: counts[doc["...
259
1
'''simple docstring''' import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_commo...
634
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : Tuple = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['Luk...
634
1
'''simple docstring''' import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_at...
39
'''simple docstring''' import re def __lowerCAmelCase ( lowerCamelCase : str ): '''simple docstring''' __lowerCAmelCase = re.compile( r"^(?:0|94|\+94|0{2}94)" r"7(0|1|2|4|5|6|7|8)" r"(-| |)" r"\d{7}$" ) return bool(re.search(lowerCamelCase , lowerC...
39
1
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modelin...
694
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCamelCase : str = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeo...
284
0
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> bool: snake_case_ = [int(_SCREAMING_SNAKE_CASE ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(_SCREAMING_SNAKE_CASE ) == 4 and all(0 <= int(_SCREAMING_SNAKE_CASE ) <= 254 for o...
709
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> int: if index == number_of_items: return 0 snake_case_ = 0 snake_case_ ...
2
0
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_swi...
0
from __future__ import annotations from math import pow, sqrt def __lowercase( UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ ): """simple docstring""" if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError("One and only one argume...
623
0
"""simple docstring""" class lowerCAmelCase__ : '''simple docstring''' def __init__( self ): _lowerCamelCase : List[Any] = 0 _lowerCamelCase : int = 0 _lowerCamelCase : Any = {} def A_ ...
492
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretra...
492
1
"""simple docstring""" from __future__ import annotations class lowercase__ : '''simple docstring''' def __init__( self : List[str] , _UpperCAmelCase : int ) -> None: '''simple docstring''' ...
82
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class _UpperCAmelCase : def __init__( self , lowercase_ ) -> None: UpperCAmelCase = value UpperCAmelCase = None ...
373
0
'''simple docstring''' from collections.abc import Sequence def a ( __a , __a ) -> float: '''simple docstring''' return sum(c * (x**i) for i, c in enumerate(__a ) ) def a ( __a , __a ) -> float: '''simple docstring''' ...
280
'''simple docstring''' import numpy as np def a ( __a , __a , __a , __a , __a ) -> Union[str, Any]: '''simple docstring''' UpperCamelCase__ :Tuple = int(np.ceil((x_end - xa) / h ) ) UpperCamelCase__ :Optional...
280
1
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeli...
24
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class UpperCAmelCase ( nn.Module ): def __init__( self : int , __lowerCamelCase : int = 1_6 , __lowerCamelCase ...
467
0
'''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_available(): ...
644
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class __a (lowerCamelCase , ...
644
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ :List[Any] = { """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_av...
150
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __lowercase () -> str: """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename fr...
150
1
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import Seque...
720
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) ...
647
0
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...t...
548
from __future__ import annotations def A__ ( lowerCamelCase ) -> bool: UpperCamelCase_: Optional[int] = len(lowerCamelCase ) # We need to create solution object to save path. UpperCamelCase_: List[str] = [[0 for _ in range(lowerCamelCase )] for _ i...
548
1
'''simple docstring''' import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py A__ : Union[str, Any] ...
721
'''simple docstring''' import random def a_ ( _UpperCAmelCase : list ,_UpperCAmelCase : List[Any] ) -> tuple: __snake_case , __snake_case , __snake_case : int = [], [], [] for element in data: if element...
124
0
def UpperCamelCase ( ) -> int: '''simple docstring''' return 1 def UpperCamelCase ( _a ) -> int: '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def UpperCamelCase ( _a ...
257
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 if is_...
257
1
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, ) _lowerCamelCase : Tuple = ...
704
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase (__lowerCamelCase ): """simple docstring""" UpperCAmelCase_ = ["image_processor", "tokenizer"] UpperCA...
157
0
from copy import deepcopy class lowercase_ : def __init__( self , lowercase_ = None , lowercase_ = None) -> None: if arr is None and size is not None: a__ =size a__ =[0] * size elif arr is not None: ...
20
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.set_...
20
1
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaStructTextConfig, ...
707
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTeste...
199
0
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects import *...
454
from math import sqrt def lowerCAmelCase_ ( __lowerCamelCase = 1_0_0_0_0_0_0 ): __snake_case : int = 0 __snake_case : int = 0 __snake_case : int while num_cuboids <= limit: max_cuboid_size += 1 ...
81
0
"""simple docstring""" from __future__ import annotations class _lowercase : """simple docstring""" def __init__( self : str , UpperCamelCase__ : Optional[int]=None ) -> List[Any]: '''simple docstring''' ...
705
"""simple docstring""" import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def...
296
0
"""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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
95
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def __lowerCamelCase ( A__ ) -> str: """simple docstring""" if not sentence: return "" UpperCamelCase = dict(zip(A__ , A__ ) ...
430
0
"""simple docstring""" import os def UpperCAmelCase ( ): """simple docstring""" A__ = os.path.dirname(os.path.realpath(UpperCamelCase__ ) ) A__ = os.path.join(UpperCamelCase__ , 'triangle.txt' ) w...
536
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_avai...
536
1
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.uti...
155
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 100 ): __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "...
155
1
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel...
113
'''simple docstring''' from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from...
113
1
import argparse import datetime def a (lowerCAmelCase__ ): __a = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wednesday""", """4""": """Thursday""", """5""": """Friday""", """6""": """Saturday"""...
99
'''simple docstring''' def _lowerCAmelCase ( _lowerCAmelCase = 10_00 )-> int: __UpperCAmelCase = 2**power __UpperCAmelCase = 0 while n: __UpperCAmelCase , __UpperCAmelCase = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input())....
126
0
import gc import threading import time import psutil import torch class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self )-> List[Any]: '''simple docstring''' __UpperCamelCase = psutil.Process() __Upp...
451
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
451
1
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_t...
6
'''simple docstring''' import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def a__ ( a__ ): """simple docstring""" __SCREAMING_SNAKE_CASE = {} __SCREAM...
627
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging __SCREAMING_SNAKE_CASE : Dict ...
705
from __future__ import annotations import bisect def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ = 0 ,lowerCAmelCase__ = -1 ): if hi < 0: lowercase = len(lowerCAmelCase__ ) while lo < hi: lowercase = lo + (hi - lo) //...
72
0
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline fr...
459
'''simple docstring''' import argparse from collections import defaultdict import yaml _UpperCamelCase = 'docs/source/en/_toctree.yml' def a_ ( _lowerCAmelCase ) -> Any: __lowerCamelCase : Optional[int] = defaultdict(_lowerCAmelCase ) __lowerCam...
459
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_...
443
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def SCREAMING_SNAKE_CASE_ ( __A :...
443
1
"""simple docstring""" import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __lowercase ( __lowerCamelCase ): snake_case_ = """""" snake_case_ ...
65
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessi...
690
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, re...
172
'''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 _A ( UpperCamelCase ): '''simple ...
172
1
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _lowerCamelCase ( lowerCamelCase__ : List[Any] , lowerCamelCase__ : str , lowerCamelCase__ : ...
200
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig...
200
1
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py lowerCamelCase : Union[str, Any] = '.' if __name__ == "__main__": lowerCamelCase : int = os.path.join(REPO_PATH, 'utils/documentation_t...
708
import inspect import unittest class __lowercase (unittest.TestCase ): """simple docstring""" def UpperCAmelCase ( self ) -> List[Any]: try: import diffusers # noqa: F401 except ImportError: assert False def UpperC...
684
0
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class a__ ( _lowercase ): __magic_name__ : U...
507
'''simple docstring''' from __future__ import annotations def __lowercase (_SCREAMING_SNAKE_CASE :list[int] ): if not nums: return 0 SCREAMING_SNAKE_CASE : Tuple = nums[0] SCREAMING_SNAKE_CASE : Union[str, Any] = 0 for num in nums[1:]: SC...
507
1
SCREAMING_SNAKE_CASE__ = 8.314_462 # Unit - J mol-1 K-1 def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> float: if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('Invalid inputs. Enter positive value.' ) return moles * kelvin * UNIVE...
52
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.append(os.p...
52
1
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig A : Tuple = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-la...
128
'''simple docstring''' import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP A : List[Any] = False try: A : ...
128
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _lowerCAmelCase ...
708
from collections.abc import Generator from math import sin def _lowerCAmelCase ( __lowerCamelCase : bytes ): """simple docstring""" if len(__lowerCamelCase ) != 32: raise ValueError("Input must be of length 32" ) __SCREAMING_SNAKE_CASE : Union[str, Any] ...
447
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils impo...
168
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer UpperCAmelCase__ : int = logging.get_logg...
313
0
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split a_ = datasets.load_iris() a_ = np.array(data['data']) a_ = np.array(data['target']) a_ = data['target_names'] a_ , ...
707
'''simple docstring''' from __future__ import annotations from collections.abc import Callable a_ = list[list[float | int]] def _a( UpperCamelCase__ : Matrix, UpperCamelCase__ : Matrix ): '''simple docstring''' SCREAMING_SNAKE...
665
0
'''simple docstring''' UpperCAmelCase : List[Any] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def a__ ( ): """simple docstring""" __SCREAMING_SNAKE_CASE = input("""Enter message: """ ) __SCREAMING_SNAKE_CASE = input("""Enter key [alphanumeric]: """ ) __SCREAMING_S...
627
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
0
'''simple docstring''' def _snake_case ( A ) -> List[str]: if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True lowerCAmelCase__ = 4 lowerCAmelCase__ = (1 << p) - 1 for _ in range(p - 2 ): lowerCAmel...
707
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docs...
98
0
"""simple docstring""" def __UpperCAmelCase ( lowercase ): """simple docstring""" return credit_card_number.startswith(("""34""", """35""", """37""", """4""", """5""", """6""") ) def __UpperCAmelCase ( lowercase ): """simple docstring""" _UpperCAmelCase ...
277
"""simple docstring""" import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attenti...
277
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: if not is_torch_available(): rai...
718
import math UpperCamelCase = 1_0 UpperCamelCase = 7 UpperCamelCase = BALLS_PER_COLOUR * NUM_COLOURS def _a ( lowerCamelCase__ = 20 ) -> str: lowerCamelCase_ : List[str] = math.comb(lowerCamelCase__ , lowerCamelCase__ ) lowerCamelCase_ ...
144
0
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class UpperCAmelCase_ (_UpperCAmelCase ): """simple docstring""" lowerCamelCase : Optional[int] = 'EncodecFeatureE...
13
'''simple docstring''' from collections.abc import Callable import numpy as np def _snake_case ( A , A , A , A , A ) -> np.array: lowerCAmelCase__ = int(np.ceil((x_end - xa) / step_size ) ) lowerCAmelCase__ ...
90
0
import warnings warnings.warn( """memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: """ """`from accelerate import find_executable_batch_size` to avoid this warning.""", FutureWarning, )
703
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between che...
25
0
'''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 from ...utils.backbone_utils import BackboneConfigMixin, ge...
596
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 lowerCamelCase ( a_ ...
318
0
'''simple docstring''' import requests UpperCamelCase__ : Dict = '''https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=''' def __UpperCamelCase( _A : List[str] ): '''simple docstring''' # fetching a list of articles in json format UpperCAmelCase__ : Any ...
711
'''simple docstring''' def __UpperCamelCase( _A : str , _A : str ): '''simple docstring''' UpperCAmelCase__ : int = len(_A ) UpperCAmelCase__ : int = len(_A ) UpperCAmelCase__ : int = ( first_str_length if first_str_length >...
496
0
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn from ...
686
"""simple docstring""" import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class lowerCamelCase__ ( lowerCamelCase_ ): @require_torch def lowerCamelCase_ ...
134
0
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def UpperCAmelCase ( a_, a_, a_, a_, a_, a_, a_, a_, a_, ): '''simple docstring''' for nxt, d in graph[v]: if nxt in visited_forward: continue lowerCamelCase : ...
133
"""simple docstring""" import os import pytest from attr import dataclass _A = 'us-east-1' # defaults region @dataclass class _lowercase : lowercase_ = 42 lowercase_ = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' lowercase_ = { 'task_name...
133
1
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import Fl...
637
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : Optional[Any] = logging.get_logger(__name__) __a : Dict = { "google/realm-cc-news-pretrained-embedder": ( "https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/c...
637
1
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDi...
488
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
488
1
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require_...
108
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json", "tiiua...
18
0
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_t...
446
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ : str = {"""processing_layoutxlm""": ["""LayoutXL...
446
1
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase (a_ ): snake_case_ = (IPNDMScheduler,) snake_case_ = (("""num_inference_steps""", 50),) def __UpperCAmelCase ( self ...
367
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase (a_ ): snake_case_ = (PNDMScheduler,) snake_case_ = (("""num_inference_steps""", 50),) def __UpperCAmelCase ( self ,...
367
1
"""simple docstring""" from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __UpperCamelCase ( ): A_ : str = HfArgumentParser(snake_case__ ) A_ : str = parser.parse_args_into_dataclasses()[0] A_ : Any = TensorFlowBen...
480
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): """simple docstring""" _A : Optional[int] = ["""image_processor""", """tokenizer"""] _A ...
480
1
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TY...
260
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffus...
260
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __UpperCamelCase : Dict = 0 __UpperCamelCase : Any = [ [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, 0, 0, 0, 0, 0], ...
712
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast fr...
372
0
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 ): __snake_case :int __snake_case :int __snake_case :float = 0....
80
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _A = logging.getLogger(__name__) class A ( __UpperCAmelCase ): def __init__( self, UpperCamelCase__=-1 ): ...
431
0
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __A = (720, 1280) # Height, Width __A = (0.4, 0.6) # if height or width lower than this scale, drop it. __A = 1 / 100 __A = '''''' __A = '''''' _...
366
"""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_funnel import FunnelTokenizer __A = logging.get_logger(__name__) __A = {'''vocab...
366
1