code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class lowerCAmelCase__ ( _lowerCamelCase ): def __init__( self : Any , __UpperCamelCase : Union[str, Any] , __UpperCamelCase : U...
106
"""simple docstring""" import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __lowercase : Optional[int] = logging.getLogger(__name__) class lowerCAmelCase ( a ): ...
142
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer _lowercase : Dict =logging.get_logger...
721
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np _lowercase : Optional[Any] =re.compile(R"\b(a|an|the)\b", re.UNICODE) _lowercase : Dict =None def __UpperCAmelCase ( ) -> List[st...
574
0
'''simple docstring''' _SCREAMING_SNAKE_CASE = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "a", 11: "b", 12: "c", 13: "d", 14: "e", 15: "f", } def __a(SCREAMING_SNAKE_CASE_ : float ...
18
import numpy as np def __a ( __UpperCAmelCase : np.ndarray ) -> np.ndarray: """simple docstring""" return 1 / (1 + np.exp(-vector )) def __a ( __UpperCAmelCase : np.ndarray ) -> np.ndarray: """simple docstring""" ...
488
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :str = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :Union[str, Any] = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus...
119
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def UpperCAmelCase_ ( _...
119
1
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaP...
173
'''simple docstring''' import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers f...
173
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class a__ ( A__ ): @staticmethod @abstractmethod def lowerCamelCase_ ( _lowerCamelCase :ArgumentParser ): '''simple docstring''' raise NotImple...
395
"""simple docstring""" from __future__ import annotations def A_ ( __lowercase ): UpperCamelCase_ : List[Any] =0.00 UpperCamelCase_ : Dict =0 for resistor in resistors: if resistor <= 0: UpperCamelCase_ : List[str] =F'''Resistor at index {index} ha...
395
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean A : Any = 0 A : List[Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], ...
140
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a__ ( __UpperCamelCase ): SCREAMING_SNA...
140
1
import logging from transformers.configuration_utils import PretrainedConfig UpperCamelCase__ : Optional[int] = logging.getLogger(__name__) class lowerCAmelCase_ ( lowerCamelCase_ ): __a : Optional[Any] = "masked_bert" def __init__( self ...
685
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def __UpperCAmelCase ( lowerCamelCase_ : int ) -> Union[str, Any]: """simple docstring""" def is_in_circle(lowerCamelCase_ : float , ...
685
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.se...
621
"""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_pipeli...
573
0
"""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 im...
439
"""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 Schedul...
439
1
def UpperCamelCase (lowercase_: int ) -> int: if not isinstance(lowercase_ , lowercase_ ): A__ : int = f"""Input value of [number={number}] must be an integer""" raise TypeError(lowercase_ ) if number < 1: A__ : Any = f"""Input value of [number={number}] m...
456
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient A_ : str = WebClient(token=os.environ['CI_SLACK_BOT_TOKEN']) def UpperCamelCase (lowercase_: Union[str, Any] ) ->...
456
1
"""simple docstring""" from functools import lru_cache @lru_cache def A_ ( _lowerCAmelCase : int ): """simple docstring""" if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ...
285
"""simple docstring""" def A_ ( _lowerCAmelCase : list, _lowerCAmelCase : list, _lowerCAmelCase : int ): """simple docstring""" _a = len(_lowerCAmelCase ) _a = [[0] * n for i in range(_lowerCAmelCase )] for i i...
285
1
'''simple docstring''' from sklearn.metrics import matthews_corrcoef import datasets A__ : Any = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes i...
13
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow ...
261
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase : int ={ "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"], "tokenization_m2m_1...
15
from math import log from scipy.constants import Boltzmann, physical_constants lowerCAmelCase : List[Any] =300 # TEMPERATURE (unit = K) def A__ ( __A , __A , __A , ): '''simple docstring''' if donor_conc <= 0: raise ValueError("""Dono...
15
1
from __future__ import annotations snake_case_ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] snake_case_ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def snake_case__ ( SCREAMING_SNAKE_CASE_ : list[float] ): '''simple doc...
164
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self , a = 6): lowercase__ : Node | None = None lowercase__ : Node | None = None self.create_linked_list(a) def snake_case_ ( self , a)...
164
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from...
520
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> int: """simple docstring""" if len(_lowerCAmelCase ) != len(_lowerCAmelCase ): raise ValueError("""The length of profit and weight must be same.""" ) if max_weight <= 0: raise Va...
520
1
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils import r...
290
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "C...
267
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ : Dict = logging.get_logger(__name__) UpperCAmelCase__ : Union[str, Any] = { 'kssteven/...
706
import argparse import copy def _A( UpperCamelCase__ : Union[str, Any] ) -> Tuple: '''simple docstring''' __lowercase = {} with open(UpperCamelCase__ ) as f: for line in f: if line.split()[0] not in dict_of_neighbour...
362
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/r...
80
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } class __magic...
358
0
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be consid...
186
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class A_ ( pl.LightningModule ): '''simple docstring''' def __init__( self , _A) -> List[str]:...
186
1
"""simple docstring""" def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ...
82
def _lowercase ( __UpperCamelCase : list ): snake_case__ = False while is_sorted is False: # Until all the indices are traversed keep looping snake_case__ = True for i in range(0 , len(__UpperCamelCase ) - 1 , 2 ): # iterating o...
214
0
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast...
687
'''simple docstring''' from __future__ import annotations import requests __snake_case : Union[str, Any] = set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category c...
687
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decoder...
546
'''simple docstring''' import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patc...
546
1
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging lowerca...
58
'''simple docstring''' from __future__ import annotations lowercase_ = 10 def UpperCamelCase__ ( a__ ): '''simple docstring''' _lowerCAmelCase =1 _lowerCAmelCase =max(a__ ) while placement <= max_digit: # declare and initializ...
58
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = { 'roberta-base': 'http...
220
def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : str ,lowerCAmelCase_ : str ) -> list: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] =len(lowerCAmelCase_ ) SCREAMING_SNAKE_CASE_ : List[Any] =[] for i ...
220
1
from typing import Any def A ( lowercase ) -> list[Any]: '''simple docstring''' if not input_list: return [] UpperCamelCase = [input_list.count(lowercase ) for value in input_list] UpperCamelCase = max(lowercase ) # Gets the maximum count in the input list. # Get...
713
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, )...
3
0
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.data imp...
70
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, Ber...
70
1
from collections import namedtuple import requests from lxml import html # type: ignore __lowerCamelCase : Any = namedtuple("""covid_data""", """cases deaths recovered""") def A__ ( _a : str = "https://www.worldometers.info/coronavirus/" ): '''simple docstring''' ...
448
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": __lowerCamelCase : List[str] = argparse.ArgumentParser() parser.add_argument( """--checkpoint_path""", ...
448
1
'''simple docstring''' from typing import Any def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , ): _validation( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
585
"""simple docstring""" 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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from tra...
308
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, Ef...
702
'''simple docstring''' # Copyright 2023 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/LICE...
40
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Dict = logging.get_logger(__name__) class __magic_name__ ( _lowercase ): UpperCamelCase_ = '''encoder-decoder''' UpperCamelCase_ = True ...
353
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation UpperCAme...
420
0
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedule...
703
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_c...
193
0
"""simple docstring""" lowerCAmelCase__ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def lowercase__ ( ): _SCREAMING_SNAKE_CASE : str = input('Enter message: ' ) _SCREAMING_SNAKE_CASE : Optional[int] = input('Enter key [alphanumeric]: ' ) _SCREAMING_...
621
"""simple docstring""" def lowercase__ ( lowerCamelCase, lowerCamelCase ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
621
1
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, Train...
16
"""simple docstring""" # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .forma...
16
1
"""simple docstring""" 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 ModelT...
273
"""simple docstring""" 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 ...
273
1
UpperCamelCase = """ # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git """ UpperCamelCase = [{"""type""": """code""", """content""": INSTALL_CONTENT}] UpperC...
152
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): return getitem, k def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): return setitem, k, v...
152
1
from __future__ import annotations from fractions import Fraction def __UpperCAmelCase ( __a : int ,__a : int ) -> bool: """simple docstring""" return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) ...
14
'''simple docstring''' import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP UpperCamelCase__ = False try: UpperCamelC...
620
0
'''simple docstring''' import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() __A = logging.get_logger(__name__) __A = [ ['''attention''', '...
61
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { '''configuration_distilbert'...
61
1
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowercase__ ( unittest.TestCase ): """simple docstring""" def _a ( self ...
102
'''simple docstring''' class _lowercase : '''simple docstring''' def __init__( self : List[Any] , SCREAMING_SNAKE_CASE__ : int ) -> None: __lowerCAmelCase = size __lowerCAmelCase = [0] * size __lowerCAmelCase = [0] * size ...
427
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_snake_case ) class A_ ( _snake_case ): '''simple docstring''' ...
695
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) fr...
695
1
'''simple docstring''' from collections.abc import Callable def SCREAMING_SNAKE_CASE_ ( __A : Callable[[float], float] , __A : float , __A : float ) -> float: _SCREAMING_SNAKE_CASE = a _SCREAMING_SNAKE_CASE = b if function(__A ) == 0: # o...
418
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { 'uw-madison/mra-base-512-4': 'https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json', } c...
418
1
'''simple docstring''' import heapq def lowerCamelCase_ ( UpperCamelCase__ : dict ): '''simple docstring''' UpperCamelCase__ = [] # for each node and his adjacency list add them and the rank of the node to queue # using hea...
719
import csv import tweepy # Twitter API credentials lowercase = """""" lowercase = """""" lowercase = """""" lowercase = """""" def lowerCamelCase_ ( UpperCamelCase__ : str ): '''simple docstring''' ...
591
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TY...
43
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONF...
258
0
'''simple docstring''' def UpperCAmelCase ( A : str ): SCREAMING_SNAKE_CASE : Dict = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) SCREAMING_SNAKE_CASE : Tuple ...
464
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('''repo_id''' , ['''canonical_dataset_name''', '''org-name/dataset-name'''] ) @pytest.mark.parametrize('''path''' , ['''filename.csv''', '''filename ...
464
1
"""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/...
76
"""simple docstring""" __A : Optional[int] = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio fro...
602
0
'''simple docstring''' 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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.ut...
711
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extracti...
331
0
'''simple docstring''' from math import factorial def lowercase__( _UpperCamelCase : int , _UpperCamelCase : int )-> int: """simple docstring""" if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n >= k" ) return factorial(...
138
'''simple docstring''' def lowercase__( _UpperCamelCase : int = 100 )-> int: """simple docstring""" _UpperCamelCase = set() _UpperCamelCase = 0 _UpperCamelCase = n + 1 # maximum limit for a in range(2 , _UpperCamelCase ): for...
138
1
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionM...
672
'''simple docstring''' a : Tuple = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def __lowerCamelCase ( _lowercase ) -> int: UpperCAmelCase : str = 0 while number: # Increased Speed Slightly by checking ev...
672
1
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit...
63
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...ut...
234
0
"""simple docstring""" from __future__ import annotations UpperCamelCase_ : Union[str, Any] = '''#''' class __lowerCAmelCase : """simple docstring""" def __init__( self : Any ) -> None: """simple docstring""" A_ = {} def ...
482
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tra...
482
1
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
359
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
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def snake_case_ ( lowerCAmelCase_ : bytes , lowerCAmelCase_ : int ): __lowercase : List[str] = F"{sampling_rate}" __low...
649
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
649
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging lowerCamelCase__ = logging.get_logger(__name__) def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Tuple=None , _SCREAMING_S...
225
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging lowerCamelCase__ = logging.get_logger(__name__) def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Tuple=None , _SCREAMING_S...
225
1
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _Upp...
328
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseCon...
328
1
'''simple docstring''' import requests __SCREAMING_SNAKE_CASE : Tuple ='https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : str ): '''simple docstring''' A: List[Any] = reques...
135
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __SCREAMING_SNAKE_CASE : str =TypeVar('KEY') __SCREAMING_SNAKE_CASE : Dict =TypeVar('VAL') @dataclass(frozen=snake_case_ , ...
135
1
"""simple docstring""" def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> "list[int]": if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) SCREAMING_SNAKE_CASE = [0] * (upper_limit + 1) # Base cas...
327
"""simple docstring""" import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.t...
327
1
"""simple docstring""" import gc import threading import time import psutil import torch class __lowerCamelCase : def __init__(self ): '''simple docstring''' _lowerCAmelCase = psutil.Process() _lowerCAmelCase = False def A__ ...
156
"""simple docstring""" import os def __UpperCAmelCase ( snake_case_ : str = "input.txt" ) -> int: """simple docstring""" with open(os.path.join(os.path.dirname(snake_case_ ) , snake_case_ ) ) as input_file: _lowerCAmelCase = [ [int(sna...
156
1
"""simple docstring""" def lowercase ( UpperCamelCase : int , UpperCamelCase : int ): """simple docstring""" return 1 if input_a == input_a else 0 def lowercase ( ): """simple docstring""" assert xnor_gate(0 , 0 ) == 1 assert xn...
700
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : Dict = { "configuration_rembert": ["REMBER...
595
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class a ( a__ ): snake_case__ = '''SpeechT5FeatureExtractor''' snake_case__ = '''SpeechT5Tokenizer''' def __init__( self , _snake_case , _snake_case ): ...
4
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils i...
215
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges ...
169
def A (__A : list , __A : list , __A : int , __A : int , __A : int ) -> int: """simple docstring""" if index == number_of_items: return 0 UpperCAmelCase_ = 0 ...
169
1
'''simple docstring''' import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMo...
476
'''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.utils ...
476
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase__ = { '''configuration_encodec''': [ '''ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
702
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeq...
598
0
def __snake_case ( _lowerCAmelCase : int = 1 , _lowerCAmelCase : int = 1000 ) -> int: A_ : Optional[int] = 1 A_ : int = 0 for divide_by_number in range(_lowerCAmelCase , digit + 1 ): A_ : list[i...
454
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def __snake_case ( _lowerCAmelCase : List[str] , _lowerCAmelCase : Union[str, Any]=1 ) -> Any: if n_shave_prefix_segments >= 0: return ".".join(path.spli...
454
1
'''simple docstring''' from __future__ import annotations import requests def UpperCamelCase_ ( snake_case_ : str ) -> dict: '''simple docstring''' __lowerCAmelCase = f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" ret...
330
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_util...
330
1
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def A__ ( lowercase: str = "" ) -> dict[str, float]: A : str =url or 'https://www.imdb.com/chart/top/?ref_=nv_mv_250' A : Tuple =BeautifulSoup(requests.get(low...
305
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _lowercase : str =( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _lowercase : list[int] =[ord(letter) for letter in string.ascii_lowercas...
305
1
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_ava...
720
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def lowerCAmelC...
517
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowerCAmelCase (__UpperCamelCase ): '''simple docstring''...
584
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fro...
584
1
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency UpperCAmelCase_ = { '''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''': ...
721
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switch...
519
0
"""simple docstring""" from collections import deque class lowercase__ : '''simple docstring''' def __init__( self : int , _UpperCAmelCase : str , _UpperCAmelCase : int , _UpperCAmelCase : int )...
82
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ...
82
1
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : int = 1 , UpperCAmelCase__ : int = 1_0_0_0 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ :List[Any] = 1 SCREAMING_SNAKE_CASE__ :List[str] = 0 ...
718
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase ( UpperCAmelCase__ : List[Any] , Upp...
320
0
"""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 C...
346
"""simple docstring""" from functools import lru_cache def a__ ( __SCREAMING_SNAKE_CASE ) -> set: __lowerCAmelCase: Any = 2 __lowerCAmelCase: Optional[Any] = set() while i * i <= n: if n % i: i += 1 else: n...
346
1
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline _UpperCamelCase : Optional[Any] =logging.get_logg...
575
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCamelCase : Tuple ={ "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], }...
575
1
import os import sys import unittest 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_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init...
74
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class __lowercase ( UpperCamelCase ): """simple d...
605
0
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase ) -> float: if not nums: raise ValueError("""List is empty""" ) return sum(__lowerCAmelCase ) / len(__lowerCAmelCase ) if __name__ == "__main__": impor...
12
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...
12
1
def UpperCamelCase( __UpperCamelCase : int ): if length <= 0 or not isinstance(snake_case__ ,snake_case__ ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(snake_case__ )] if __name__ == "__main__": print(hexagonal_...
171
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_util...
543
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regre...
709
'''simple docstring''' import argparse import json import subprocess def UpperCamelCase ( lowercase_ : List[Any] , lowercase_ : Tuple ) -> Union[str, Any]: '''simple docstring''' lowercase =[] lowercase =( f'curl -H "Accept: application/vnd.github+...
145
0
from __future__ import annotations import math class _A : '''simple docstring''' def __init__( self ,SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case : Dict = size # approximate the overall size of segment tree with given value snake_ca...
36
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 lowerCAmelCase__ :int = logging.get_logger(__name__) def lowerCAmelCase__ ( a__: Dict ) -> List[str]: '''simple ...
618
0
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
702
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availabl...
535
0
def UpperCamelCase ( ) -> List[str]: UpperCamelCase : Optional[Any] = 0 for i in range(1 , 1001 ): total += i**i return str(snake_case__ )[-10:] if __name__ == "__main__": print(solution())
40
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import SequenceFeatureExtractio...
40
1
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAG...
704
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy _lowercase : List[Any] =logging.get_logger(__na...
661
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : Tuple = logging.get_logger(__name__) a : Tuple = {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''} class SCR...
69
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int = 1_00_00_00 ) -> int: __snake_case = 1 __snake_case = 1 __snake_case = {1: 1} for inputa in range(2 , _UpperCAmelCase ): __snake_case = 0 __snake_case = inputa ...
69
1
__lowercase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.609_344, "knot": 1.852, } __lowercase : dict[str, float] = { "km/h": 1.0, "m/s": 0.277_777_778, "mph": 0.621_371_192, "knot": 0.539_956_803, } def lowercase ( __A : ...
315
def lowercase ( __A : Dict ) -> Optional[Any]: '''simple docstring''' snake_case : Union[str, Any] = len(__A ) for i in range(length - 1 ): snake_case : Dict = i for k in range(i + 1 , __A ): if collection[k] <...
315
1
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_...
433
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_av...
433
1
'''simple docstring''' from PIL import Image def _lowerCamelCase( UpperCamelCase__ : Image , UpperCamelCase__ : int ) -> Image: A : Tuple = (259 * (level + 255)) / (255 * (259 - level)) def contrast(UpperCamelCase__ : int ) -> int: return...
537
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if i...
537
1
def _A ( __snake_case :int ) -> int: """simple docstring""" assert isinstance(__snake_case , __snake_case ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: __SCREAMING_SNAKE_CASE = f'''The inp...
693
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): def __init__( self, *_a, **_a ) -> ...
693
1
"""simple docstring""" import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class snake_case ( UpperCAmelCase ): __mag...
720
"""simple docstring""" # coding=utf-8 # Copyright 2023 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 #...
118
0
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase__( UpperCAmelCase ): ...
97
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __snake_case = logging.ge...
472
0
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSeq...
714
'''simple docstring''' def lowerCAmelCase_ ( __A : int = 1_00 ): '''simple docstring''' snake_case: List[str] = n * (n + 1) * (2 * n + 1) / 6 snake_case: List[Any] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) ...
692
0
"""simple docstring""" import inspect import unittest from transformers import MobileViTConfig 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 ...
273
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ......
146
0
from __future__ import annotations from collections.abc import Iterator from typing import Any class a__ : '''simple docstring''' def __init__( self , _A ): """simple docstring""" __lowerCAmelCase = data __lowerCAmelCase ...
705
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_available(): ...
552
0
'''simple docstring''' import math def A_( A : int): UpperCamelCase = 0 UpperCamelCase = 0 while num > 0: UpperCamelCase = num % 8 UpperCamelCase = octal + (remainder * math.floor(math.pow(10 , A...
3
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class SCREAMING_SNAKE_CASE__ : def __init__( self )-> Dict: '''simple docstring''' UpperCamelCase = ...
3
1
from __future__ import annotations def a(lowercase__ , lowercase__ ): '''simple docstring''' if len(lowercase__ ) < k or k < 0: raise ValueError('Invalid Input' ) snake_case_ = snake_case_ = sum(array[:k] ) for i in range(len(lowercase__ ) - k ): snake_case_ = current_sum - ar...
703
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'microsoft/unispeech-sat-base-100h-libri-ft': ( 'https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolv...
46
0
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def __UpperCamelCase ( _A ): return 1 / (1 + np.exp(-z )) def __UpperCamelCase ( _A , _A ...
431
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore...
235
0
import argparse import datetime def UpperCAmelCase_ ( __UpperCamelCase ): SCREAMING_SNAKE_CASE__ ={ """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wednesday""", """4""": """Thursday""", """5""": """Friday""", ...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase_ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise OptionalDependencyNo...
588
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'hustvl/yolos-smal...
685
import argparse import os 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_task_guides.py __UpperCAmelCase = '''src/transformers''' __UpperCAmelCase = '''docs/source...
40
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
571
def UpperCamelCase__ ( _A: int ): '''simple docstring''' if not isinstance(_A , _A ): __lowerCamelCase = f'''Input value of [number={number}] must be an integer''' raise TypeError(_A ) if number < 0: ...
571
1
"""simple docstring""" # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class lowerCAmelCase ( lowerCamelCase_ ): '''simple docstring''' def __init__...
247
"""simple docstring""" import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) class lowerCAmelCase ( lowerCamelCase_ ...
247
1
def _lowerCAmelCase( __A ): UpperCAmelCase = len(__A ) UpperCAmelCase = len(matrix[0] ) UpperCAmelCase = min(__A , __A ) for row in range(__A ): # Check if diagonal element is not zero if matrix[row][row] != 0: # Eliminate all the elements...
1
def _lowerCAmelCase( __A ): if not isinstance(__A , __A ): raise TypeError("only integers accepted as input" ) else: UpperCAmelCase = str(abs(__A ) ) UpperCAmelCase = [list(__A ) for char in range(len(__A ) )] for index in range(len(__A ) ): ...
1
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers,...
173
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: lowerCAmelCase_ = None try: import msvcrt except ImportError: lowerCAmelCase_ = None try: import fcntl except ImportError: lowerCAmelCase_ = None # ...
173
1
from ... import PretrainedConfig lowercase_: int = { 'sijunhe/nezha-cn-base': 'https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json', } class lowercase__ (__lowerCamelCase ): __UpperCamelCase : Dict = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP __U...
714
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 if is_torch_available(): import torch if i...
127
0