code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 #...
75
"""simple docstring""" import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def __magic_name__ ( __snake_case : Optional[Any] , __snake_case : ...
202
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
75
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model outputs. Read the documenta...
75
1
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow a_ = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.' ) @require_torch @...
76
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , A : Any ) ->Optional[int]: lowerCamelCase__ : Optional[int] = data lowerCamelCase__ : Any = None class __SCREAMING_SNAK...
142
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a = logging.get_logger(__name__) def _snake_case ( _snake_case : Union[tf.Tensor, np.ndarray] ) -> List[int]: '''simple d...
271
"""simple docstring""" from __future__ import annotations import time import numpy as np a = [8, 5, 9, 7] a = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a = [ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, ...
271
1
from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 lowerCAmelCase_ = { # 1536-bit 5: { '''prime''': int( ...
8
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from tr...
104
0
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device...
367
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case : Union[str, Any] = logging.get_logger(__name__) snake_case : List[Any] = { "junnyu/roformer_chin...
41
0
'''simple docstring''' def _UpperCamelCase ( __A ) -> list: '''simple docstring''' UpperCamelCase__ = len(__A ) for i in range(1 , __A ): UpperCamelCase__ = collection[i] UpperCamelCase__ = 0 ...
80
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ :Optional[Any] = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConf...
277
0
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class A : """simple docstring""" lowerCamelCase = None lowerCamelCase = False lowerCamelCase = F...
282
import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMi...
282
1
'''simple docstring''' def a_ ( __snake_case : list ) -> bool: """simple docstring""" if not isinstance(__snake_case , __snake_case ): raise ValueError('''Input series is not valid, valid series - [2, 4, 6]''' ) if len(__sna...
75
'''simple docstring''' import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
75
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Union[str, Any] = logging.get_logger(__name__) _snake_case : Dict = { 's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json', } class _UpperCAmelC...
360
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 _snake_case : Union[str, Any] = False try: _snake_case ...
207
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """BloomOnnxConfi...
271
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __lowerCAmelCase = TypeVar("""T""") class UpperCAmelCase__ ( Generic[T] ): """simple docstring""" def __init__( self : Tuple ,_a :...
271
1
def snake_case_ ( lowerCAmelCase_ : int , lowerCAmelCase_ : int ): return int((input_a, input_a).count(1 ) != 0 ) def snake_case_ ( ): assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == 1 assert or_gate(1 , 0 ) == 1 ass...
306
def snake_case_ ( lowerCAmelCase_ : int = 200 ): __lowercase : List[str] = [1, 2, 5, 10, 20, 50, 100, 200] __lowercase : List[str] = [0] * (pence + 1) __lowercase : Optional[Any] = 1 # base case: 1 way to make 0 pence ...
306
1
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class _SCREAMING_SNAKE_CASE ( _a ): def __init__( self : str , __lowerCamel...
38
'''simple docstring''' from __future__ import annotations import requests _A : str =set( '''approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post catego...
41
0
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import torch.nn as nn ...
71
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness _lowercase: Optional[Any] = "\\n@misc{chen2021evaluating,\n title={Evaluating Large ...
71
1
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRuntimeModel ...
282
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging _lowerCamelCase : List[str] = logging.get...
282
1
'''simple docstring''' import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils im...
136
'''simple docstring''' from __future__ import annotations from typing import Any class lowerCamelCase : '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase_ : int ) -> None: '''simple docstring''' A__ : Any =num...
136
1
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...
5
from math import asin, atan, cos, radians, sin, sqrt, tan A__ : Optional[int] = 637_8137.0 A__ : List[str] = 635_6752.31_4245 A__ : Union[str, Any] = 6_37_81_37 def a ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): '''simple do...
207
0
from __future__ import annotations def UpperCamelCase ( _A ): """simple docstring""" if len(_A ) < 2: raise ValueError("""Monogons and Digons are not polygons in the Euclidean space""" ) if any(i <= 0 for i in nums ): raise ValueError("""All...
138
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps,...
138
1
def __lowerCamelCase ( snake_case__ ,snake_case__ ) -> float: """simple docstring""" if density <= 0: raise ValueError("""Impossible fluid density""" ) if bulk_modulus <= 0: raise ValueError("""Impossible bulk mo...
306
import argparse import hashlib # hashlib is only used inside the Test class import struct class __UpperCAmelCase : def __init__( self: List[str] , UpperCAmelCase_: Dict ): '''simple docstring''' _SCREAMING_SNAKE_CASE ...
306
1
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image fro...
79
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Any = {'''configuration_fnet''': ['''FNET...
79
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 ...
71
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness A_ :List[str] = '''\ @misc{chen2021evaluating, title={Ev...
71
1
def lowerCAmelCase_ ( _snake_case : list ) -> float: '''simple docstring''' __magic_name__ : Any = 0 while len(_snake_case ) > 1: __magic_name__ : List[Any] = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): ...
41
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
41
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization...
136
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> list: '''simple docstring''' lowercase_ = len(__lowerCAmelCase ) lowercase_ = [[0] * n for i in range(__lowerCAme...
136
1
'''simple docstring''' from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmb...
9
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets _UpperCAmelCase : List[str] = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the gro...
9
1
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.modeling_roberta_series import ( ...
138
from datetime import datetime as dt import os from github import Github __A : Dict = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def SCREAMING_SNAKE_CASE__ ( ) -> int...
138
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _snake_case : Optional[Any] = logging.get_logger(__name__) _snake_case ...
179
'''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 from d...
179
1
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDi...
79
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # S...
79
1
"""simple docstring""" import re def UpperCAmelCase ( UpperCamelCase__ ): """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(UpperC...
154
"""simple docstring""" def UpperCAmelCase ( UpperCamelCase__ = 100 ): """simple docstring""" A__ = (n * (n + 1) // 2) ** 2 A__ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main_...
154
1
'''simple docstring''' from __future__ import annotations from statistics import mean def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase , UpperCamelCase ) -> list[int]: lowerCamelCase__ : Any = [0] * no_of_pro...
41
'''simple docstring''' import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, ...
41
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case...
124
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE :str = 'docs/source/en/_toctree.yml' def UpperCAmelCase ( a_ ) -> int: """simple docstring""" __A = defaultdict(a_ ) for doc in model_doc: ...
124
1
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph class ...
9
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 import ( is_pipeline_test, nes...
9
1
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> float: '''simple docstring''' _UpperCAmelCase : Dict = (num_of_terms / 2) * (...
371
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : List[str] ) -> str: '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase : Dict = [], [] while len(SCREAMING_SNAKE_CASE__ ) > 1: _UpperCAmelCase , _Up...
202
0
"""simple docstring""" import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, ...
179
"""simple docstring""" import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, ...
179
1
import numpy as np def _SCREAMING_SNAKE_CASE ( lowercase : np.ndarray ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def _SCREAMING_SNAKE_CASE ( lowercase : np.ndarray ): '''simple docstring''' ...
367
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image f...
208
0
import math 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 SchedulerMixin, SchedulerOutput class _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ , lowerCAmelCase__): _Uppe...
154
def __UpperCamelCase ( _A : Dict ) ->List[str]: """simple docstring""" lowerCamelCase_ =[0] * len(_A ) lowerCamelCase_ =[] lowerCamelCase_ =[] lowerCamelCase_ =0 for values in graph.values(): for i in ...
154
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def a__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMIN...
133
"""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...
133
1
from __future__ import annotations from decimal import Decimal from numpy import array def SCREAMING_SNAKE_CASE__ ( lowercase ) -> list[list[float]]: snake_case : Optional[Any] = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implem...
124
import math def SCREAMING_SNAKE_CASE__ ( lowercase ) -> int: if not isinstance(lowercase ,lowercase ): snake_case : List[Any] = f"""Input value of [number={number}] must be an integer""" raise TypeError(lowercase ) if number < 1: snake...
124
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table impor...
59
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that ...
59
1
'''simple docstring''' from sklearn.metrics import mean_squared_error import datasets _UpperCamelCase : Tuple = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. a...
304
"""simple docstring""" from __future__ import annotations from functools import lru_cache from math import ceil _A : Optional[Any] = 1_00 _A : Optional[int] = set(range(3, NUM_PRIMES, 2)) primes.add(2) _A : int for prime in range(3, ceil(NUM_PRIMES**...
202
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''xlm-...
334
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/f...
334
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCAmelCase = { '''configuration_efficientformer''': [ ...
298
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def a_ ( *_lowerCAmelCase ,_lowerCAmelCase = None ,_lowerCAmelCase=True ,_lowerCAmelCase=2 ) -> List[str]: fr...
208
0
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : str ): """simple docstring""" if n_term == "": return [] __UpperCamelCase =[] for temp in range(int(snake_case__ ) ): series.append(F"""1/{temp + 1}""" if series else '''1''' ) retu...
365
"""simple docstring""" import os from pathlib import Path def lowerCAmelCase (): """simple docstring""" from torch.utils.cpp_extension import load __UpperCamelCase =Path(__UpperCamelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' __Uppe...
85
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class __lowerCAmelCase ( ...
133
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 from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKIN...
133
1
'''simple docstring''' import numpy as np def lowercase_ ( __A , __A , __A , __A , __A ) -> Union[str, Any]: _snake_case = int(np.ceil((x_end - xa) / h ) ) _snake_case = np.zeros((n + 1,) ) _snake_case ...
368
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class __UpperCAmelCase : def __init__( self ): """simple docstring""" _snake_case = [] _snake_case = 0 _snake_case...
160
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = R""" Args: input_ids (`torch.L...
59
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def UpperCamelCase ( __lowerCamelCase : Dataset , __lowerCamelCase : Dict[str, str] ): ...
59
1
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder _A : int = '__DUMMY_TRANSFORMERS_USER__' _A : List[Any] = 'Dummy User' _A : Optional[Any] = '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' _...
353
from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Any = logging.get_logger(__name__) _A : int = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class __SCREAMING_SNAKE_CASE ( lowerCAmelCase...
265
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ={"vocab_file": "vocab.json", "merges_file...
334
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokenizer,...
334
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 UpperCAmelCase : Any = logging.getLogger(__name__) class lowerCAmelCase__ ( __lowercase )...
361
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) # TODO: upload to AWS UpperCAmelCase : Optional[int] = { 'yjernite/retribert-base-uncased': ( 'https...
331
0
'''simple docstring''' def __lowercase ( __lowercase ) -> bool: '''simple docstring''' return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
79
'''simple docstring''' import warnings from functools import wraps from typing import Callable def UpperCamelCase_( snake_case : Callable ): '''simple docstring''' @wraps(snake_case ) def _inner_fn(*snake_case : Optional[int] , **snak...
85
0
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def _lowercase ( _UpperCAmelCase , _UpperCAmelCase = "cpu" , _UpperCAmelCase = None ) -> None: lowerCamelCase =torch.load(_UpperCAmelCase , map_location=_UpperCAmelCase ) ...
352
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig UpperCAmelCase__ : Optional[Any] ={ '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pyt...
262
0
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Tuple = logging.get_logger(__name__) A__ : Optional[Any] = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''xlnet-large-cas...
103
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_ima...
160
0
'''simple docstring''' import inspect 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_config_docstrings.py UpperCamelCase : Union[str, Any] = ...
360
'''simple docstring''' import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common impo...
345
0
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigT...
133
'''simple docstring''' from itertools import count def __lowerCamelCase ( _lowercase = 5_0 ) -> int: UpperCAmelCase : Any = [1] * min_block_length for n in count(_lowercase ): fill_count_functions.append(1 ) for block_length in...
265
0
from __future__ import annotations from fractions import Fraction def __UpperCAmelCase ( UpperCAmelCase_ : Any , UpperCAmelCase_ : Dict ) -> bool: '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / ...
361
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_d...
95
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 lowerCamelCase : Any = logging.get_logger(__name__) lowerCamelCase : D...
47
'''simple docstring''' 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 ( ...
331
0
def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase, __lowerCamelCase = 0, __lowerCamelCase = 0 ): _SCREAMING_SNAKE_CASE : Any = right or len(__lowerCamelCase ) - 1 if left > right: return -1 elif list_data[left] == key: retu...
354
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCamelCase__ =logging.get_logger(__name__) class lowerCAmelCase__( __lowercase ): '''simple docstring''' def __init__( self , *__lowerCamelCase ...
325
0
from queue import PriorityQueue from typing import Any import numpy as np def __A ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , )-> float | int: ...
39
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import to...
262
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_d...
211
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = OrderedDict( [ ...
211
1
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __A = logging.get_logger(__name__) def lowerCAmelCase_ ( __a ) -> int: """simple docstring""" lowerCamelCase...
10
from ..utils import DummyObject, requires_backends class _snake_case ( metaclass=__snake_case ): '''simple docstring''' A__ : Tuple = ["flax"] def __init__( self: str ,*lowerCamelCase_: int ,**lowerCamelCase_: List[str] ) -> str: requires...
345
0
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__) UpperCamelCase__ = { '''goo...
355
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__ ( unittest.TestCase ): @prop...
102
0
"""simple docstring""" from __future__ import annotations import math def a_ ( lowerCamelCase , lowerCamelCase ): if len(lowerCamelCase ) != 2 or len(a[0] ) != 2 or len(lowerCamelCase ) != 2 or len(b[0] ) != 2: raise Exception('Matrices are not 2x2' ...
98
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class __lowerCAmelCase : pass
95
0
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( 'The `image_to_image.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionImg2ImgPipeline` instead.' )
361
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE...
194
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Tuple = logging.get_logger(__name__) __lowerCamelCase : str = { '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/resolve/...
18
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE__ = """src/transformers""" # Matches is_xxx_available() SCREAMING_SNAKE_CASE__ = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} SCREAMING_SNAKE_CASE...
325
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ = { '''configuration_efficientformer''': [ '''EFFICIENTFORMER_PRET...
175
"""simple docstring""" import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, Dist...
175
1
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging lowercase_ ...
211
'''simple docstring''' from __future__ import annotations from typing import TypedDict class __A ( A ): '''simple docstring''' __lowerCamelCase : str __lowerCamelCase : int def lowerCAmelCase (__A): """simple docstring""" if not isinstance(__A...
211
1
"""simple docstring""" import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _SCREAMING_SNAKE_C...
239
"""simple docstring""" from __future__ import annotations import math def __lowerCamelCase ( a_ : int , a_ : int , a_ : bool , a_ : list[int] , a_ : float ) -> int: if depth < 0: raise Va...
239
1
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy ...
25
"""simple docstring""" import math def lowercase ( _snake_case : int ) ->bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ar...
102
0
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseMod...
358
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer ...
58
0
from collections import deque def _A ( SCREAMING_SNAKE_CASE : List[str] ): """simple docstring""" a__ : str =len(SCREAMING_SNAKE_CASE ) a__ : Tuple =deque() a__ : List[Any] =[False for _ in range(SCREAMING_SNAKE_...
95
"""simple docstring""" import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers impor...
194
0
"""simple docstring""" import requests from bsa import BeautifulSoup def _lowerCamelCase(__UpperCamelCase = "https://www.worldometers.info/coronavirus" ) -> dict: _lowerCAmelCase =BeautifulSoup(requests.get(__UpperCamelCase ).text , """html.parser""" ) _lowerCAmelCase =soup....
341
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], 'tokenizati...
341
1
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation a_ = ...
175
from __future__ import annotations def __lowercase ( lowerCamelCase : Optional[Any] , lowerCamelCase : Dict , lowerCamelCase : Union[str, Any] , lowerCamelCase : List[str] ): # noqa: E741 while r - l > 1: UpperCamelCase_ : Union[str, Any] = (l + r)...
175
1
'''simple docstring''' lowercase__ = 9.8_06_65 def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = g ) -> float: '''simple docstring''' if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) i...
83
'''simple docstring''' 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 lowercase__ = logging.get_logger(__name__) lowercase__ ...
83
1
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list[int] ) -> int: if not numbers: return 0 if not isinstance(UpperCAmelCase__ , (list, tuple) ) or not all( isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) for n...
239
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn #...
239
1
'''simple docstring''' def a__ ( lowercase : int ) -> bool: """simple docstring""" if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True _UpperCamelCase = 4 _UpperCamelCase = (1 << p) - 1 fo...
356
'''simple docstring''' def a__ ( lowercase : int, lowercase : int ) -> int: """simple docstring""" return x if y == 0 else greatest_common_divisor(lowercase, x % y ) def a__ ( lowercase : int, lowercase : int ) -> int: """simple docstrin...
287
0
"""simple docstring""" import math def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> str: SCREAMING_SNAKE_CASE = 0 SCREAMING_SNAKE_CASE = 0 while num > 0: SCREAMING_SNAKE_CASE = num % 8 SCR...
113
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import...
58
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class __A ( _SCREAMING_SNAKE_CASE ): """simple docstring""" __lowerCAmelCase = "WhisperFeatureExtractor" __lowerCAmelCase = "WhisperTokenizer" def __init__( self ...
363
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image ...
215
0
'''simple docstring''' import requests from bsa import BeautifulSoup def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE = "https://www.worldometers.info/coronavirus" ): _snake_case = BeautifulSoup(requests.get(_SCREAMING_SNAKE_CASE ).text , """html.parser""" ) ...
341
'''simple docstring''' 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, requi...
341
1
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: _UpperCAmelCase : Any = None try: import msvcrt except ImportError: _UpperCAmelCase : Any = None try: import fcntl except ImportError:...
9
'''simple docstring''' from __future__ import annotations import math def __magic_name__( lowerCamelCase, lowerCamelCase): if len(lowerCamelCase) != 2 or len(a[0]) != 2 or len(lowerCamelCase) != 2 or len(b[0]) != 2: raise Exception('''Matrices are not 2x2''') __lowerC...
9
1
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging snake_case_ : str = '\\n\n' snake_case_ : str = '\nPerplexity (PPL) is one of the most common m...
83
'''simple docstring''' def A__ ( UpperCAmelCase_ ): _UpperCamelCase : List[str] = abs(UpperCAmelCase_ ) _UpperCamelCase : int = 0 while n > 0: res += n % 1_0 n //= 1_0 return res def A__ ( UpperCAmelCase_ ): ...
83
1
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): import ...
131
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load...
131
1
'''simple docstring''' A__ : str = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import ...
185
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
287
0
# Lint as: python3 import itertools import os import re snake_case_ = re.compile(r'''([A-Z]+)([A-Z][a-z])''') snake_case_ = re.compile(r'''([a-z\d])([A-Z])''') snake_case_ = re.compile(r'''(?<!_)_(?!_)''') snake_case_ = re.compile(r'''(_{2,})''') snake_case_ = r'''^\w+...
216
import math import sys def snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' if number != int(SCREAMING_SNAKE_CASE_ ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the valu...
216
1
__snake_case = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", """flax""": """flax>=0.4.1""", """hf-doc-builder"...
259
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.ut...
215
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A : List[Any]...
8
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __A : Optional[int] = logging.get_logger(__name__) class __UpperCamelCase ( lowercase__ ): def __init__( self :List[str] ,*_Upp...
8
1
import logging import os import threading import time try: import warnings except ImportError: __lowerCAmelCase : List[str] =None try: import msvcrt except ImportError: __lowerCAmelCase : List[Any] =None try: import fcntl except ImportError: __lowerCAmelCase : str ...
9
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _lowercase ( unittes...
9
1
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_co...
14
def lowerCamelCase ( a_ ) -> bool: lowerCAmelCase_ = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowerCAmelCase_ = set() return any( node not in visited and depth_first_s...
14
1
# Lint as: python3 import itertools import os import re lowerCamelCase = re.compile(R'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase = re.compile(R'''([a-z\d])([A-Z])''') lowerCamelCase = re.compile(R'''(?<!_)_(?!_)''') lowerCamelCase = re.compile(R'''(_{2,})''') lowerCamelCase ...
131
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( _lowercase): _a : Union[str, Any] = ['''image_processor''', '''tokenizer'''] _a : List[Any] = '''ChineseCLIPImageProcess...
131
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaV...
42
import os def __lowerCamelCase ( __magic_name__ : str = "input.txt" ): with open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) ) as input_file: a__: str =[ [int(__magic_name__ ) for element in line.split("," )] ...
42
1
import random from typing import Any def __UpperCamelCase ( lowerCAmelCase__ : list ): for _ in range(len(lowerCAmelCase__ ) ): __a : Optional[Any] = random.randint(0 , len(lowerCAmelCase__ ) - 1 ) __a : Union[str, Any] = random.randint(0 , len(lowerCAmelCase__ ) -...
216
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency lowercase__ ={ 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, 'C': 2.78, 'U': 2.76, 'M': 2.41, ...
216
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transformers.utils im...
279
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __lowerCAmelCase ( nn.Module ): lowerCamelCase_ : int lowerCamelCase_ : int lowerCamelCase_ ...
279
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = '''▁''' lowerCAm...
8
import math def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(SCREAMING_SNAKE_CASE__ ) else: if x == 0: ...
8
1
"""simple docstring""" import pickle import numpy as np from matplotlib import pyplot as plt class __a : '''simple docstring''' def __init__( self , _a , _a , _a , _a , _a , _a=0.2 , _a=0.2 ) -> Optional[Any]: """simple ...
56
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0...
56
1
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig 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 ...
14
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> List[Any]: """simple docstring""" A__ ...
14
1
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def UpperCAmelCase__ (snake_case__ : int = 8 ): """simple docstring""" _snake_case : List[str] = ascii_letters + ...
359
"""simple docstring""" import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from...
132
0
'''simple docstring''' from __future__ import annotations class __UpperCAmelCase : def __init__( self , lowerCAmelCase_ ): """simple docstring""" _snake_case = TypeError( 'Matrices must be formed from a list of zero or more lists ...
42
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
42
1
'''simple docstring''' def _A ( A__ = 1000 ): """simple docstring""" __lowercase , __lowercase = 1, 1 __lowercase = 2 while True: __lowercase = 0 __lowercase = fa + fa __lowercase , __lowercase = fa, f index += 1 for _...
52
'''simple docstring''' import string def _A ( A__ ): """simple docstring""" for key in range(len(string.ascii_uppercase ) ): __lowercase = '''''' for symbol in message: if symbol in string.ascii_uppercase: __lowercase = string.ascii_uppercase.find(A__...
52
1
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from tr...
279
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class __lowerCAmelCase ( _a ): lowerCamelCase_...
279
1
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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/...
243
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ : List[Any] = { 'configuration_vision_text_dual_encoder': ['...
243
1
'''simple docstring''' import re def __magic_name__ ( __UpperCAmelCase ) -> bool: '''simple docstring''' snake_case_ = 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(__UpperCAmelCase, __U...
56
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simp...
56
1
'''simple docstring''' import math from collections.abc import Iterator from itertools import takewhile def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number ...
101
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax impo...
101
1