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
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record lowercase : Union[str, Any] = """\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems}, author={W...
302
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 transformers.utils im...
302
1
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline...
716
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def a__ ( lowerCAmelCase : List[str] ): '''simple docstring''' def wrapper(*lowerCAmelCase : Any , ...
660
0
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :int ): __UpperCAmelCase = [True] * limit __UpperCAmelCase = False __UpperCAmelCase = False __UpperCAmelCase = True for i in range(3 , int(limi...
49
from __future__ import annotations lowerCAmelCase__ : Union[str, Any] =[ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def a__ ( A__, A__, A__, A__, A__, ): SCREAMING_SNAKE_CASE_ : List[Any] = ...
101
0
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. _snake_case = 10 def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _l...
708
def A ( _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : int = len(_lowerCamelCase ) for i in range(1 , _lowerCamelCase ): _lowerCAmelCase : List[Any] = collection[i] ...
658
0
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 UpperCAmelCase ( __snake_case ): def __init__( self ...
386
def __lowerCamelCase ( _lowercase ) -> list: for i in range(len(_lowercase ) - 1 , 0 , -1 ): UpperCamelCase = False for j in range(_lowercase , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: ...
282
0
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): _lowerCAmelCase : List[str] = f"""Input value of [number={number}] must be an integer""" raise Type...
16
"""simple docstring""" from collections.abc import Callable class __UpperCamelCase : def __init__( self ,_A = None ): '''simple docstring''' _lowerCAmelCase : list = [] # Stores indexes of each item for supporting updates and deletion....
16
1
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union __A = TypeVar("""T""") __A = Union[List[T], Tuple[T, ...]] __A = Union[T, List[T], Dict[str, T]] __A = Union[str, bytes, os.PathLike]
93
from typing import TYPE_CHECKING from ....utils import _LazyModule _lowercase = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _lowercase = _LazyModule(__name__, globals()['''__file__'''...
659
0
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
113
'''simple docstring''' import os def _UpperCamelCase ( UpperCamelCase__ = "input.txt" ): with open(os.path.join(os.path.dirname(UpperCamelCase__ ) , UpperCamelCase__ ) ) as input_file: UpperCAmelCase__ : Tuple = [ [int(Up...
113
1
from __future__ import annotations from math import pi def _a ( lowercase__ : float , lowercase__ : float , lowercase__ : float ): '''simple docstring''' if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError('One and only one argument...
85
"""simple docstring""" from math import sqrt def UpperCAmelCase ( A : int = 100_0000 ): '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase = 0 _UpperCAmelCase = 42 while num_cuboids <= limit: max_cuboid_size += 1 ...
573
0
"""simple docstring""" __UpperCAmelCase ={ """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", "...
712
"""simple docstring""" import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase =...
261
0
from __future__ import annotations __a = list[list[int]] # assigning initial values to the grid __a = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0, 5, 0, ...
30
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, ...
30
1
import argparse import os import re import packaging.version _lowercase = "examples/" _lowercase = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$", re.MULTILINE)...
713
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCAmelCase__ ( UpperCamelCase_ : dict )-> tuple: ...
526
0
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCAmelCase_ : _UpperCamelCase : Dict = 42 _UpperCamelCa...
66
def a__ ( A__ = 5_0_0_0_0_0_0_0 ): SCREAMING_SNAKE_CASE_ : Union[str, Any] = set() SCREAMING_SNAKE_CASE_ : Optional[int] = int((limit - 2_4) ** (1 / 2) ) SCREAMING_SNAKE_CASE_ : Dict = set(range(3, prime_square_limit + 1, 2 ) ) ...
101
0
from __future__ import annotations a_ : Optional[Any] = 'Muhammad Umer Farooq' a_ : List[Any] = 'MIT' a_ : Optional[Any] = '1.0.0' a_ : List[Any] = 'Muhammad Umer Farooq' a_ : Union[str, Any] = 'contact@muhammadumerfarooq.me' a_ : Optio...
148
from __future__ import annotations import unittest from transformers import LEDConfig, 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 from ...test_pipeline_mixin im...
148
1
'''simple docstring''' def UpperCamelCase_ ( A__ : int ): '''simple docstring''' if not isinstance(A__ , A__ ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) lowerCAmelCase_ : Any = str(A__ ) lowerCAmelC...
275
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __A : Union[str, Any] = TypeVar("KEY") __A : Union[str, Any] = TypeVar("VAL") @dataclass(frozen=_SCREAMING...
275
1
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTest...
210
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->bool: """simple docstring""" a_ = 0 for ch in input_str: a_ = ord(UpperCAmelCase ) a_ = pow(2 , UpperCAmelCase ) # If we already turned on bit for current character's...
210
1
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...te...
35
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available a_ :List[Any] = logging.getLogger(__name__) @dataclass class ...
35
1
"""simple docstring""" import math def lowercase_ ( _snake_case ): if not isinstance(_lowerCAmelCase ,_lowerCAmelCase ): SCREAMING_SNAKE_CASE__ : List[Any] = f'''Input value of [number={number}] must be an integer''' raise TypeError(_lowerCAmelCase ) ...
716
"""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_image_inputs ...
545
0
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase ) -> list: '''simple docstring''' if any(not isinstance(__snake_case , __snake_case ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for ...
109
"""simple docstring""" def A ( __snake_case: str ) -> list: """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__snake_case ) ) if txt[a].isalpha() ] if __name__ == "...
545
0
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def snake_case__ ( UpperCAmelCase : Optional[int] ): lowerCAmelCase__ :List[Any] = args.pruning_method lowerCAmelCase__ ...
704
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 _a : Tuple = logging.get_logger(__name__) _a : Optional[int] = { """fac...
111
0
"""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_pipe...
103
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
336
0
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class lowerCAmelCase__ ( UpperCamelCase_ ): @staticmethod @abstractmethod def lowercase_ ( UpperCamelCase__ ): '''simple docstring''' r...
712
"""simple docstring""" import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase =...
261
0
"""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_video_inputs if is_...
264
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional impo...
282
0
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetYaaagf ...
714
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json""", # See all ViT MAE models at https://huggingface.co/models?f...
286
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _a = logging.get_logger(__name__) _a = { """shi-labs/nat-mini-in...
19
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils ...
319
0
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, ...
718
'''simple docstring''' lowercase_ = ''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/tran...
58
0
from __future__ import annotations def a_ ( lowerCAmelCase_ : list[int], lowerCAmelCase_ : int, lowerCAmelCase_ : int, lowerCAmelCase_ : int ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ...
53
'''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 _UpperCamelCase = logging.get_logger(__name__) _UpperCam...
111
0
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _A : Optional[Any] = datasets.utils.logging.get_logger(__name__) class _lowercase ( folder_...
330
'''simple docstring''' from ...processing_utils import ProcessorMixin class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' _SCREAMING_SNAKE_CASE : str = """WhisperFeatureExtractor""" _SCREAMING_SNAKE_CASE : Any = """WhisperTokenizer...
330
1
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _snake_case (__lowercase , __lowercase , __lowercase , __lowercase , __lowercase = None , __lo...
23
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: UpperCAmelCase =...
84
0
import os def lowerCamelCase__ ( ): '''simple docstring''' snake_case_ = os.path.join(os.path.dirname(_A ) , "num.txt" ) with open(_A ) as file_hand: return str(sum(int(_A ) for line in file_hand ) )[:10] if __name__...
139
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class UpperCAmelCase ( UpperCAmelCase__ ): '''simple...
139
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 snake_case = { # 1536-bit 5: { """prime""": int( ...
67
'''simple docstring''' import os from datetime import datetime as dt from github import Github _lowerCAmelCase = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '''wip''', ] de...
565
0
from ...processing_utils import ProcessorMixin class a (_lowerCAmelCase ): """simple docstring""" __UpperCAmelCase : Any = "SpeechT5FeatureExtractor" __UpperCAmelCase : Union[str, Any] = "SpeechT5Tokenizer" def __init__( s...
203
import unittest import numpy as np def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase = None , ): __snake_case : List[str] = np.shape(__lowerCamelCase ) __snake_case : Optional[Any] ...
203
1
from __future__ import annotations from decimal import Decimal from numpy import array def A_ ( _lowerCAmelCase ) -> list[list[float]]: UpperCamelCase : List[str] = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for ...
629
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging __lo...
629
1
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenc...
718
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
84
0
import numpy # List of input, output pairs A_ : Any = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) A_ : List[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) A_ : ...
57
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = { 'configuration_deberta': ['DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Debe...
665
0
import 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 _lowercase = logging.get_logger(__name__) _lowercase = {'''...
714
from __future__ import annotations from random import random class __snake_case : """simple docstring""" def __init__( self : Optional[int] ,lowerCAmelCase__ : int | None = None ) -> int: '''simple docstring''' lowerCAmelCase_ : Dict ...
683
0
import glob import os import random from string import ascii_lowercase, digits import cva lowerCamelCase_ = '''''' lowerCamelCase_ = '''''' lowerCamelCase_ = '''''' lowerCamelCase_ = 1 # (0 is vertical, 1 is horizontal) def __magic_name__ ( ): '''simple docstring...
513
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''InstructBlipQFormerConfig'''...
513
1
import math def __lowercase ( _SCREAMING_SNAKE_CASE ) -> list: '''simple docstring''' SCREAMING_SNAKE_CASE = [True] * n SCREAMING_SNAKE_CASE = False SCREAMING_SNAKE_CASE = False SCREAMING_SNAKE_CASE = True for i in range(3 ...
116
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_D...
116
1
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version UpperCAmelCase : List[str] = version.parse(importlib_metadata.version("""nltk""")) if NLTK_VERSION >= version.Version("""3.6.4"""): from nltk ...
563
from itertools import count def _A ( SCREAMING_SNAKE_CASE : int = 50 ): """simple docstring""" a__ : Union[str, Any] =[1] * min_block_length for n in count(SCREAMING_SNAKE_CASE ): fill_count_functions.append(1 ) for block_length in range(SCREAM...
563
1
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand UpperCamelCase_ = ( "4S 3H 2C 7S 5H", "9D 8H 2C 6S 7H", "2D 6D 9D TH 7D", "TC 8C 2S JH 6C", "JH 8S TH AH QH", "TS KS 5S 9S AC", "KD 6S 9D TH AD", "KS ...
712
def lowerCamelCase_ ( _a : list ): '''simple docstring''' for i in range(len(_a ) - 1 , 0 , -1 ): UpperCAmelCase_ : Optional[int] = False for j in range(_a , 0 , -1 ): if unsorted[j] < unsorted[j ...
322
0
'''simple docstring''' import argparse from collections import defaultdict def lowercase_ ( __A : Optional[Any] , __A : Optional[int] , __A : str , __A : Tuple , __A : int ) -> Dict: """simple docstring""" ...
94
'''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, resize, to_c...
94
1
import fire from utils import calculate_rouge, save_json def __A ( _lowercase , _lowercase , _lowercase=None , **_lowercase ): '''simple docstring''' _A = [x.strip() for x in open(_lowercase ).readlines()] _A = [x.strip() for x in open(_lowerc...
700
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig __A = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE : """simple docstring""" ...
62
0
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ : List[str] ) -> Dict: # This defines a "chinese character" as anything in the CJK Unicode block: ...
287
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ : int = 2_00_00_00 ) -> int: _lowercase = [0 for i in range(n + 1 )] _lowercase = 1 _lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_lis...
287
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json''' ), ...
715
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=_UpperCAmelCase) class __lowercase ( _UpperCAmelCase): """simple docstring""" ...
48
0
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _a ( yaml.SafeLoader): def __lowercase ( self : List[Any] , _lowercase : Dict ) -> Union[str, Any]...
449
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) A = {'configuration_vit': ['VIT_PRETRAINED_CONFIG...
449
1
from collections.abc import Sequence from queue import Queue class _snake_case : def __init__( self ,UpperCamelCase ,UpperCamelCase ,UpperCamelCase ,UpperCamelCase=None ,UpperCamelCase=None ) -> Tuple: snake_case__ :Any = ...
57
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
57
1
'''simple docstring''' def lowerCamelCase__ ( _A ): return credit_card_number.startswith(('34', '35', '37', '4', '5', '6') ) def lowerCamelCase__ ( _A ): a : Optional[int] = credit_card_number a : List[Any] = 0 a : Tuple = len(_A ) - 2 for i in range(_A...
526
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase: List[str] = logging.get_logger(__name__) lowerCAmelCase: int = { 'bert-bas...
526
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black lowercase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa...
704
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
695
0
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 __lowercase ( __snake_case ): UpperCam...
377
import argparse import os import re import packaging.version __a = """examples/""" __a = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(R"""^__version__\s+=\s+\"([^\"]+)\"\s...
377
1
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase : List[Any] ...
706
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, ...
651
0
'''simple docstring''' import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from ....
44
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTo...
44
1
"""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, Di...
529
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_...
529
1
from __future__ import annotations def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> Union[str, Any]: """simple docstring""" if len(lowerCamelCase__ ) <= 1 or n <= 1: return insert_next(lowerCamelCase__ , n - 1 ) rec_insertion_sort...
252
'''simple docstring''' from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np fr...
131
0
"""simple docstring""" import math UpperCamelCase_ : Optional[int] = 10 UpperCamelCase_ : int = 7 UpperCamelCase_ : List[Any] = BALLS_PER_COLOUR * NUM_COLOURS def __lowercase ( a : int = 20 ) -> Any: __snake_case : Dict =math.co...
705
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ : Optional[Any] = logging.get_logger(__n...
497
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, id...
43
class _a : def __init__( self: Tuple , UpperCamelCase_: Dict ) -> List[str]: """simple docstring""" lowercase__ = val lowercase__ = None lowercase__ = None def lowerCamelCase_ ( ...
43
1
"""simple docstring""" class _SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self: Optional[int] , __A: str = "" , __A: bool = False ): '''simple docstring''' a__ = {} # A node will b...
200
"""simple docstring""" def SCREAMING_SNAKE_CASE ( lowerCamelCase_): assert column_title.isupper() a__ = 0 a__ = len(lowerCamelCase_) - 1 a__ = 0 while index >= 0: a__ = (ord(column_title[index]) - 64) * pow(26 , ...
200
1
'''simple docstring''' def __lowercase (_SCREAMING_SNAKE_CASE :list[list[int | float]] ): SCREAMING_SNAKE_CASE : Any = len(_SCREAMING_SNAKE_CASE ) SCREAMING_SNAKE_CASE : Optional[Any] = len(matrix[0] ) SCREAMING_SNAKE_CASE : int = min(_SC...
507
'''simple docstring''' def __lowercase (_SCREAMING_SNAKE_CASE :int , _SCREAMING_SNAKE_CASE :int ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
507
1
"""simple docstring""" __lowercase = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } __lowercase = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def lowerCAmelCase (__UpperC...
296
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging __lowercase = logging.get_logger(__name__) def lowe...
296
1
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def __UpperCamelCase (_SCREAMING_SNAKE_CASE = "laptop" ) -> DataFrame: lowercase__ = F"""https://www.amazon.in/laptop/s?k={product}""" lowercase__...
235
# 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 # # Unl...
235
1
import os import sys import unittest lowercase : Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_...
704
from __future__ import annotations lowercase : Optional[int] = [True] * 1_0_0_0_0_0_1 lowercase : Tuple = 2 while i * i <= 1_0_0_0_0_0_0: if seive[i]: for j in range(i * i, 1_0_0_0_0_0_1, i): lowercase : int = False i += 1 def Upper...
584
0
from functools import reduce UpperCAmelCase_ = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" "...
2
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenizatio...
365
0
"""simple docstring""" import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets __lowerCAmelCase : Tuple = datasets.logging.get_logger(__name__) __lowerCA...
21
"""simple docstring""" from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __lowerCAmelCase : List[str] = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for Gen...
21
1
'''simple docstring''' import re from filelock import FileLock try: import nltk UpperCAmelCase__ : Union[str, Any] = True except (ImportError, ModuleNotFoundError): UpperCAmelCase__ : Tuple = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", qui...
48
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def snake_case_ ( lowerCAmelCase_ : ndarray ): return np.dot(lowerCAmelCase_ , lowerCAmelCase_ ) class lowerCAmelCase : '''simple docstring''' def __init...
149
0
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('''Googling.....''') lowerCamelCase__ = '''https://www.google.com/search?q=''' + ''' '''.join(sys.argv[1:]) lowerCamelCase__ = requests.g...
226
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __magic_name__ (__lowercase ): lowerCamelCase__ = '''''' lowerCamelCase__ = ( None # protocol passed in prefix to the ur...
226
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase__ :Union[str, Any] = logging.get_...
355
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import c...
355
1
# 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 # # Unless required by appl...
716
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 __UpperCAmelCase : Any = 0B1_0_1_1_0_0_1_1_1_1_1_0_1_1_0_0_1_0_0_1_0_0_0_0_0_1_1...
249
0
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): impor...
2
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTok...
494
0
"""simple docstring""" from math import factorial def __a ( _lowercase = 100 ): """simple docstring""" return sum(map(_lowercase , str(factorial(_lowercase ) ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: ").strip())))
121
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device UpperCAmelCase : Dict = False class __SCREAMING_SNAKE_C...
121
1
"""simple docstring""" def UpperCAmelCase_ ( __a : Dict , __a : str ): '''simple docstring''' _lowerCamelCase : int = '' for i in table: res += inp[i - 1] return res def UpperCAmelCase_ ( __a : Any ): ''...
437
"""simple docstring""" # Lint as: python3 import itertools import os import re a_ = re.compile(r"""([A-Z]+)([A-Z][a-z])""") a_ = re.compile(r"""([a-z\d])([A-Z])""") a_ = re.compile(r"""(?<!_)_(?!_)""") a_ = re.compile(r"""(_{2,})""") a_ = r"""^\w+(\.\w+)*$""" ...
437
1
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 ( AutoConfig, BartForSequenceClassification, Data...
37
import math def __lowerCAmelCase ( 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: # 0 raised to any number is 0 return 0...
37
1
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ =logging.get_logger(__name__) UpperCAmelCase__ ={ "vocab_file": "vocab.json", "tokeni...
616
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def lowerCAmelCase_ ( ): """simple docstring""" wit...
616
1
'''simple docstring''' import heapq import sys import numpy as np snake_case = tuple[int, int] class lowerCAmelCase : def __init__( self : Dict ): '''simple docstring''' lowerCAmelCase__ : List[str] = [] lowerCAmelCase__ : List[str] =...
568
'''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 @requ...
568
1
from __future__ import annotations from collections.abc import Callable __UpperCamelCase : List[str] = list[list[float | int]] def _UpperCAmelCase ( UpperCAmelCase : Matrix , UpperCAmelCase : Matrix ): """simple docstring""" __lower...
519
from __future__ import annotations def _UpperCAmelCase ( UpperCAmelCase : str , UpperCAmelCase : str ): """simple docstring""" __lowerCamelCase : int = get_failure_array(UpperCAmelCase ) # 2) Step through text searching fo...
519
1
from __future__ import annotations from random import random from typing import Generic, TypeVar UpperCamelCase = TypeVar('KT') UpperCamelCase = TypeVar('VT') class _a ( Generic[KT, VT] ): '''simple docstring''' def __init__( self , __UpperCAmelCase = "ro...
706
import os import string import sys UpperCamelCase = 1 << 8 UpperCamelCase = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLAG, 'left': 68 + ARROW_KEY_FLAG, 'mod_int...
387
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Optional[int] = logging.get_logger(__name__) lowerCamelCase__ : List[str] = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/GP...
31
UpperCAmelCase__ = '''Input must be a string of 8 numbers plus letter''' UpperCAmelCase__ = '''TRWAGMYFPDXBNJZSQVHLCKE''' def a_ (__A ) -> bool: """simple docstring""" if not isinstance(__A , __A ): __a : Any ...
351
0
import math def A_ ( a , a ): """simple docstring""" if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(a ) else: if x == 0: # 0 raised to any number is 0 return 0 ...
353
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def A_ ( a , a , a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : int = TaConfig.from...
353
1
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
27
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowercase_ = logging.get_logger(__name__) class a_ ( snake_case_ ): '''simple docstring''' def __init__( self , *A , **A ) ...
314
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration _UpperCamelCase : List[Any] =50000 _UpperCamelCase : Dict =5000 _UpperCamelCase : List[Any] =os.path.split(__file__) _UpperCamelCase : Union[str, Any] =os.path.join(RE...
702
from ...configuration_utils import PretrainedConfig _UpperCamelCase : Tuple ={ 'google/tapas-base-finetuned-sqa': ( 'https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json' ), 'google/tapas-base-finetuned-wtq': ( 'https://huggingface.co/goo...
332
0
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers fr...
65
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": A_ : int = input('Enter image url: ').strip() print(F"""Downloading image from {url} ...""") A_ : Dict = BeautifulSoup(requests.get(url).content, 'html.pa...
303
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class a ...
83
_SCREAMING_SNAKE_CASE = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-'...
83
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
62
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device _UpperCAmelCase : List[Any] = False class lowercase_ ...
107
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase = { '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if not is_torc...
41
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } ...
41
1
'''simple docstring''' def lowercase__( __UpperCamelCase: int = 10_00 ): """simple docstring""" return sum(e for e in range(3 ,__UpperCamelCase ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"""{solution() = }""")
28
import requests from bsa import BeautifulSoup def lowerCamelCase( a__ = "https://www.worldometers.info/coronavirus"): _SCREAMING_SNAKE_CASE =BeautifulSoup(requests.get(a__).text ,'''html.parser''') _SCREAMING_SNAKE_CASE =soup.findAll('''h1''') _SCREAMING_SNAKE_CASE =soup...
691
0
'''simple docstring''' import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTeste...
581
'''simple docstring''' from __future__ import annotations def a ( UpperCamelCase_ : list[float] , UpperCamelCase_ : list[float] ) -> float: snake_case__ =sorted(numsa + numsa ) snake_case__ , snake_case__ =divmod(len(UpperCamelCase_ ) , 2 ) ...
581
1
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import Scheduler...
334
'''simple docstring''' import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig __A : List[Any] = { 'facebook/maskformer-swin-ba...
334
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''shi-labs/nat-mini-in1k-...
714
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNA...
52
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=snake_case_ ) class UpperCamelCase ( snake_case_ ): U...
389
"""simple docstring""" import torch from diffusers import DiffusionPipeline class UpperCamelCase ( snake_case_ ): def __init__( self : List[Any] , UpperCAmelCase__ : str , UpperCAmelCase__ : Optional[int] ) -> str: super().__i...
389
1
def a ( A__ : str , A__ : int ) -> list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(A__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
380
from __future__ import annotations from typing import Any class __lowerCAmelCase : def __init__( self , lowerCAmelCase ) -> None: '''simple docstring''' _lowercase =num_of_nodes _lowercase =[] _lowercase...
380
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class _a ( datasets.BeamBasedBuilder ): """simple docstring""" ...
23
a__ = [0, 2, 4, 6, 8] a__ = [1, 3, 5, 7, 9] def _UpperCAmelCase ( a : int , a : int , a : list[int] , a : int ): if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return 0 for i ...
654
0
"""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_common import Con...
579
"""simple docstring""" 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 im...
579
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_ob...
194
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_ : Optional[int] = '.' # Internal TensorFlow ops that ...
194
1
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: int , SCREAMING_SNAKE_CASE_: int ) -> int: '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def lowerCAmelCase__ ( ) -> None: '''simple docstring''' ...
626
from __future__ import annotations def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: list[int] , SCREAMING_SNAKE_CASE_: list[int] , SCREAMING_SNAKE_CASE_: list[int] , SCREAMING_SNAKE_CASE_: list[list[str]] , SCREAMING_SNAKE_CASE_: int , ) -> ...
626
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : Dict = logging.get_logger(__name__) __magic_name__ : List[str] = { """microsoft/swinv2-tiny-patch4-window8-256""": ( """https...
102
def _lowercase ( a__ : list ) -> list: """simple docstring""" if any(not isinstance(a__ , a__ ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(a__ ) ): for i, (rod_upper, rod_lower) ...
147
0
from numpy import exp, pi, sqrt def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ = 0.0 ,lowerCAmelCase__ = 1.0 ): return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest doctest.testmod()
72
# using dfs for finding eulerian path traversal def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__=None ): lowercase = (path or []) + [u] for v in graph[u]: if visited_edge[u][v] is False: lowercase , l...
72
1
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __snake_case ( _lowercase): snake_case__ : Any = (DDPMScheduler,) def SCREAMING_SNAKE_CASE ( self : str , **__lowerCAmelCase ...
83
"""simple docstring""" SCREAMING_SNAKE_CASE__ : Dict =[ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, ...
434
0
"""simple docstring""" from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWit...
31
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from d...
31
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, log...
279
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils...
674
0
# 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 # # Unles...
708
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenizati...
559
0
from math import isclose, sqrt def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> tuple[float, float, float]: """simple docstring""" __SCREAMING_SNAKE_CASE: Tuple = point_y / 4 /...
202
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCAmelCase ( UpperCamelCase__ : Union[str, Any] ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE: List[Any] ...
202
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_...
18
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ : Optional[Any] = { "configuration_funnel": ["FUNNEL_PRETRAINED...
18
1