code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCamelCase (lowercase_: Optional[int] ) -> List[Any]: # encoder.embeddings are double copie...
192
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : int = logging.get_logger(__name__) A_ : Optional[Any] = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', } class _a (__mag...
192
1
def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> Dict: """simple docstring""" snake_case_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def __lowerCAmelCase (SCREAMING_SNAKE...
371
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
267
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2Stru...
108
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import R...
80
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: ...
368
"""simple docstring""" # XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowerCamelCase = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) ...
241
0
"""simple docstring""" def _snake_case ( snake_case__ : int , snake_case__ : int , snake_case__ : int ): A = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def _snake_case ( ):...
74
"""simple docstring""" import math def __UpperCAmelCase ( lowercase ): """simple docstring""" _UpperCAmelCase = [] _UpperCAmelCase = 2 _UpperCAmelCase = int(math.sqrt(lowercase ) ) # Size of every segment _UpperCAmelCase = [T...
289
0
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig 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_confi...
359
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings A_ : str = ...
316
0
from collections.abc import Callable import numpy as np def _lowerCamelCase( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ ) -> np.array: '''simple docstring''' __lowercase= int(np.ceil((x_end - xa) / step_size ) ) __lowercase= np.zeros((n + 1,) ) ...
295
def _lowerCamelCase( lowercase__ , lowercase__ , lowercase__ , lowercase__ ) -> Union[str, Any]: '''simple docstring''' __lowercase= [False] * len(lowercase__ ) __lowercase= [] queue.append(lowercase__ ) __lowercase= True while queue: __lowercase= queue.pop(0 ) ...
295
1
from __future__ import annotations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): if b == 0: return (1, 0) ((__UpperCamelCase) , (__UpperCamelCase)) =extended_euclid(SCREAMING_SNAKE_CASE__ , a % ...
117
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
117
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Union[str, Any] =logging.get_logger(__name__) UpperCAmelCase : int ={ """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/conf...
128
def _lowerCAmelCase (_lowerCAmelCase): if n_term == "": return [] UpperCamelCase_ = [] for temp in range(int(_lowerCAmelCase)): series.append(f"""1/{temp + 1}""" if series else "1") return series if __name__ == "__main__": UpperCAmelCase : ...
128
1
"""simple docstring""" import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets lowerCAmelCase_ = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks...
351
"""simple docstring""" import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_sched...
302
0
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class a ( _lowerCamelCase ): def A_ ( self : Dict , lowercase_ : float ): return 0.0 ...
56
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters a : Dict = (720, 1280) # Height, Width a : Tuple = (0.4, 0.6) # if height or width lower than this scale, drop it. a : Dict = ...
56
1
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def UpperCAmelCase ( a_ ) -> Dict: """simple docstring""" __A = [ "encoder.version", "decoder.version", "model.enc...
124
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split SCREAMING_SNAKE_CASE :Tuple = datasets.load_iris() SCREAMING_SNAKE_CASE :Dict = np.array(data['data']) SCREAMING_SNAKE_CASE :Optional[int] ...
124
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerConfig', ], } try: ...
30
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class UpperCAmelCase ( _...
15
0
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lowercase__ : int ...
289
"""simple docstring""" import baseaa def UpperCamelCase_ ( lowerCAmelCase__ : str ) -> bytes: """simple docstring""" return baseaa.aaaencode(string.encode('utf-8' ) ) def UpperCamelCase_ ( lowerCAmelCase__ : bytes ) ...
289
1
"""simple docstring""" _lowercase = '''Tobias Carryer''' from time import time class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Optional[Any] ,A_ : Optional[int] ,A_ : Any ,A_ : Union[str, Any] ,A_ : Dict=int...
74
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCAmelCase : List[str] = logging.get_logger(__name__) class lowerCAmelCase__ ...
267
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __lowercase = logging.get_logger(__name__) class _lowercase ( __a ): """simple docstring""" def __init__( self : List[str] , ...
354
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase (__UpperCamelCase : int ): """simple docstring""" __UpperCamelCase =FileLock(str(tmpdir / '''foo.lock''' ) ) __UpperCamelCase =F...
85
0
'''simple docstring''' from collections import defaultdict def A_ ( snake_case ): SCREAMING_SNAKE_CASE:Any = 1 SCREAMING_SNAKE_CASE:Optional[Any] = True for v in tree[start]: if v not in visited: ret += dfs(__UpperCamelCase ) if ret...
139
"""simple docstring""" import os def __lowerCamelCase ( ) -> Optional[Any]: """simple docstring""" lowerCAmelCase_ : Union[str, Any] = os.path.dirname(os.path.realpath(__UpperCamelCase ) ) lowerCAmelCase_ : List[str] = os.path.join(__Uppe...
241
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : int = logging.get_logger(__name__) UpperCAmelCase ...
351
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : Tuple = {'configuration_reformer': ['REFORMER_PRETRAINED_C...
331
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from t...
97
"""simple docstring""" def A ( snake_case :list[int] , snake_case :int ) -> bool: __UpperCamelCase = len(snake_case ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by...
316
0
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger UpperCAmelCase__ = get_logger(__name__) UpperCAmelCase__ = r"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)...
353
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
290
0
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake snake_case__ : List[str] = numpy.array([0, 0]) snake_case__ : List[Any] = numpy.array([0.5, 0.8_660_254]) snake_c...
117
import requests snake_case__ : int = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def _a ( lowerCamelCase: str ) -> None: '''simple docstring''' __A = requests.get(_NEWS_API + bbc_news_a...
117
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if not is_torch_available(): raise OptionalDepende...
78
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hub_ut...
78
1
def lowerCamelCase__ ( snake_case_ : str , snake_case_ : str ) -> bool: __snake_case = len(snake_case_ ) + 1 __snake_case = len(snake_case_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of ...
24
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig lowerCamelCase__ = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albert-large-v1""": """https://huggin...
302
0
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_p...
103
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
103
1
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 UpperCAmelCase ( self ) -> str: debug_launcher(te...
124
def SCREAMING_SNAKE_CASE__ ( ) -> list[list[int]]: return [list(range(1000 - i ,-1000 - i ,-1 ) ) for i in range(1000 )] lowerCamelCase : List[Any] = generate_large_matrix() lowerCamelCase : Optional[int] = ( [[4, 3, 2, -1],...
124
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase_ ={"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_AR...
128
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelin...
128
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : str = { """facebook/s2t-small-librispeech-asr""": ( """https://huggingface.co/facebook/s2t-small-librispeech-asr/reso...
50
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( _lowerCamelCase ): """simple docstring""" UpperCAmelCase = (IPNDMScheduler,) UpperCAmelCase = (("""num_inferen...
215
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''', '''BigBirdPegasusOnnxConf...
304
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 lowerCAmelCase = False class A ( unittest.TestCase ): pass @...
304
1
"""simple docstring""" import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : ...
46
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase_( snake_case : Tuple ): '''simple docstring''' snake_case_ = FileLock(str(tmpdir / "foo.lock" ) ) snake_cas...
85
0
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _SCREAMING_SNAKE_CASE : List[Any] = get_tests_dir(...
362
"""simple docstring""" import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow _SCREAMING_SNAKE_CASE : Dict = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ ...
157
0
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase = loggin...
89
'''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, AutoMode...
331
0
'''simple docstring''' from typing import TYPE_CHECKING import torch from ..models.auto import AutoModelForVisualQuestionAnswering, AutoProcessor from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class __UpperCamelCase ( lowercase__ ): ...
352
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, to...
8
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 lowercase__ = logging.get_logger(__name__) lowercase__ ...
151
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase__ = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys lowercase__ = _LazyModule...
290
0
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageRes...
306
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 ( ProphetNetForConditionalGeneration as P...
306
1
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
78
"""simple docstring""" import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO, ...
78
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_...
233
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A (snake_case__): '''simple docstring''' __lowercase: Any = ["""image_processor""", """tokenizer"""] __lowercase...
233
1
from PIL import Image def UpperCamelCase( __UpperCamelCase : Image ,__UpperCamelCase : float ): def brightness(__UpperCamelCase : int ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError('''level must be between -255.0 (black) ...
103
import argparse import os import re import packaging.version A__ : Dict = '''examples/''' A__ : Any = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.compile(R'''^__version__\s+=\s+"([^...
103
1
"""simple docstring""" from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __UpperCAmelCase ( snake_case_ : str = "" ): """simple docstring""" _lowerCAmelCase = url or """https://www.imdb.com/chart/top/?ref_=nv_mv...
366
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
317
0
import os from datetime import datetime as dt from github import Github UpperCAmelCase : Optional[int] =[ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ]...
128
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCAmelCase : Tuple =2_9979_2458 # Symbols UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase : int =symbol...
128
1
from collections import Counter from timeit import timeit def a_ ( __lowercase : str = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def a_ ( __lowercase : str = "" ) -> bool: if len(__lowercase ) == 0: ...
371
import random class SCREAMING_SNAKE_CASE__ : '''simple docstring''' @staticmethod def A ( lowercase : str ): '''simple docstring''' _snake_case = [ord(lowercase ) for i in text] _snake_case = [] _snake_case = ...
130
0
'''simple docstring''' # Imports import numpy as np class snake_case__ : def __init__( self : Optional[Any] , _A : Optional[Any]=None , _A : List[str]=None , _A : Dict=None , _A : Union[str, Any]=None , ...
304
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMu...
304
1
def snake_case_ ( snake_case ) -> list[list]: lowercase__: Union[str, Any] = current_set.copy() for row_index, row in enumerate(_lowerCAmelCase ): lowercase__: str = row[0] for column_index, column in enume...
354
from __future__ import annotations def snake_case_ ( snake_case , snake_case ) -> list[int]: lowercase__: Tuple = 0 lowercase__: str = len(snake_case ) - 1 while i < j: if nums[i] + nums[j] =...
288
0
"""simple docstring""" import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenizati...
332
def _UpperCamelCase ( snake_case__, snake_case__ ) -> str: __UpperCAmelCase : int = "" for word_or_phrase in separated: if not isinstance(snake_case__, snake_case__ ): raise Exception("join() accepts only strings to be joine...
157
0
def UpperCamelCase ( __magic_name__ : list ) -> list: """simple docstring""" if len(__magic_name__ ) <= 1: return lst lowercase__ = 1 while i < len(__magic_name__ ): if lst[i - 1] <= lst[i]: i += 1 else: lowercase_...
362
class A : '''simple docstring''' def __init__(self : int , _UpperCAmelCase : list ) -> None: """simple docstring""" lowercase__ = set_counts lowercase__ = max(_UpperCAmelCase ) lowercas...
146
0
'''simple docstring''' import fire from utils import calculate_rouge, save_json def lowerCAmelCase_ ( snake_case_ : Union[str, Any] , snake_case_ : int , snake_case_ : List[Any]=None , **snake_case_ : List[Any] ) -> Union[str, Any]: '''sim...
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase_ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try:...
8
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE__:Tuple = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], """tokeniza...
268
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from...
268
1
"""simple docstring""" class a : """simple docstring""" def __init__( self: Optional[Any] , UpperCamelCase: List[Any] ): """simple docstring""" A__ = val A__ = None A__ = No...
335
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets SCREAMING_SNAKE_CASE_ : Dict = '\\n@inproceedings{popovic-2015-chrf,\n title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation",\n author =...
335
1
"""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...
351
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a_ = "." # Intern...
163
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, RegNet...
233
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : List[str] = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.jso...
233
1
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class __lowercase : '''simple docstring''' def __init__(self ...
351
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { '''Intel/dpt-large''': '''https://huggingface....
217
0
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase = " " ) -> list: lowercase__ : Optional[int] = [] lowercase__ : Union[str, Any] = 0 for index, char in enumerate(__lowerCamelCase ): if char == se...
16
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """xlm-roberta-base""": """https://huggingface.co/xlm-roberta-base/re...
317
0
'''simple docstring''' import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class snake_case__ ( tf.keras.optimizer...
356
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = 50 ) -> int: '''simple docstring''' snake_case : Union[str, Any] = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(r...
83
0
"""simple docstring""" from cva import destroyAllWindows, imread, imshow, waitKey def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' _a : Optional[int] = img.shape[0], img.shape[1] # converting each pixel's color to its negative ...
294
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ = logging.get_logger(__name__) class snake_case__(_UpperCamelCase ): """simple docstring""" def __init__( self : Tuple , *SCREAMING_SNAKE_C...
130
0
from sklearn.metrics import fa_score import datasets __UpperCAmelCase : Optional[Any] = "\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" __UpperCAmelCase : str = "\n...
293
from __future__ import annotations from decimal import Decimal from numpy import array def A__ ( SCREAMING_SNAKE_CASE__) -> list[list[float]]: __snake_case: Any = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only wo...
293
1
"""simple docstring""" import requests from bsa import BeautifulSoup def a__ ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : dict ): '''simple docstring''' lowerCAmelCase : Optional[int] = BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE ...
108
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingT...
335
0
import pprint import requests UpperCAmelCase : Union[str, Any] = "https://zenquotes.io/api" def __lowerCamelCase ( ): '''simple docstring''' return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __lowerCamelCase ( ): '''simple docstring...
370
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowercase ( pl.LightningModule ): """simple docstring""" def __init__( self , A ) -> Any: ...
66
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) class UpperCAmelCase_ ( __lowerCAmelCase): lowerCamelCase__ = "encoder-decoder" lowerCamelCase__ = True def __init__( s...
36
import os import sys __UpperCamelCase : Optional[Any] = os.path.join(os.path.dirname(__file__), "src") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceClassi...
146
0
"""simple docstring""" import os import string import sys _lowercase : Union[str, Any] = 1 << 8 _lowercase : Optional[int] = { "tab": ord("\t"), "newline": ord("\r"), "esc": 2_7, "up": 6_5 + ARROW_KEY_FLAG, "down": 6_6 + ARROW_KEY_FLAG, "right": 6...
272
"""simple docstring""" def snake_case__ ( __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : List[Any] =[0] * len(__lowerCamelCase ) lowerCamelCase__ : List[Any] =[] lowerCamelCase__ : List[Any] =[1] * len(__lowerCamelCase ) ...
272
1
"""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/LICENSE-2.0 # ...
268
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
268
1
import argparse import json from tqdm import tqdm def __UpperCamelCase( ): __a : List[str] = argparse.ArgumentParser() # Required parameters parser.add_argument( '''--src_path''' , type=_snake_case , default='''biencoder-nq-dev.json''' , help='''Path to raw DPR tra...
352
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase__ ={ 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LayoutLMv2Config'], '...
90
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch...
163
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models ...
163
1
'''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_seque...
4
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils i...
4
1
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class a_ ( unittest.TestCase ): def lowercase_...
223
from maths.prime_check import is_prime def UpperCAmelCase_( a__ ): """simple docstring""" if not isinstance(a__ , a__ ): SCREAMING_SNAKE_CASE : List[Any] = F"""Input value of [number={number}] must be an integer""" raise TypeError(a__ ...
313
0
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def A__ ( lowerCamelCase , lowerCamelCase , lowerCamelCase = 10**-10 ) -> float: UpperCamelCase_: int = a while True: UpperCamelCase...
360
def A__ ( lowerCamelCase , lowerCamelCase ) -> list: UpperCamelCase_: Optional[int] = word.split() def justify(lowerCamelCase , lowerCamelCase , lowerCamelCase ) -> str: UpperCamelCase_: Tuple = max_width - width UpperCamelCase_: ...
223
0
from math import ceil, sqrt def lowerCAmelCase_ ( snake_case_ = 1000000 ): _A : int = 0 for outer_width in range(3,(limit // 4) + 2 ): if outer_width**2 > limit: _A : List[str] = max(ceil(sqrt(outer_width**2 - limit...
26
'''simple docstring''' def A__ ( UpperCAmelCase_ = 1 , UpperCAmelCase_ = 1_0_0_0 ): _UpperCamelCase : int = 1 _UpperCamelCase : Union[str, Any] = 0 for divide_by_number in range(UpperCAmelCase_ , digit + 1 ): _UpperCamelCase : list[int...
83
0
# 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 .formatting import TensorFormatter ...
356
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer __a :Optional[Any] = logging.get_logger(__name__) __a :Any = {...
329
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines...
293
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __A = TypeVar("""KEY""") __A = TypeVar("""VAL""") @dataclass(frozen=a , slots=a ) class _lowerCAmelCase ( Generic[...
293
1
from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> None: create_state_space_tree(__lowerCAmelCase , [] , 0 ) def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ,...
196
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Dict =logging.get_logger(__name__) class __a ( A__ ): _lowerCAmelCase : Optional[int] = '''timm_backbone''' def __init__( self : Dict ...
196
1
"""simple docstring""" import re from filelock import FileLock try: import nltk __A : int = True except (ImportError, ModuleNotFoundError): __A : List[str] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.do...
260
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __a = {"configuration_reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerC...
66
0
'''simple docstring''' def __lowercase ( __lowercase = 50 ) -> Optional[Any]: '''simple docstring''' _A = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in ran...
365
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ = {'''configuration_...
174
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''microsoft/biogpt''': '''https://huggingface.co/microsoft/biogpt/resolve/main/config.json''', # See all BioGPT models at...
272
'''simple docstring''' from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
272
1
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1_337 , num_examples=42 , dataset_name='''my_d...
19
from sklearn.metrics import matthews_corrcoef import datasets a__ : Optional[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 into accou...
19
1
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class A_ : def __init__( self : List[str] ): _UpperCAmelCase = {} def lowercase ( self : int , snake_case_ : s...
22
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transfo...
90
0
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ...
113
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> bool: if len(lowerCamelCase__ ) == 0: return False __lowerCamelCase : List[Any] = len(lowerCamelCase__ ) // 2 if a_list[midpoint] == item: retu...
113
1
'''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_...
4
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class UpperCAmelCase_ ( unittest.TestCase ): def __Upp...
4
1
"""simple docstring""" import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, pr...
355
"""simple docstring""" def lowerCamelCase ( ) -> Union[str, Any]: '''simple docstring''' __UpperCAmelCase : List[str] = [] __UpperCAmelCase : List[str] = 1 while len(_UpperCamelCase ) < 1E6: constant.append...
320
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Conf...
36
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[Any] ={ '''configuration_nllb_moe''': [ '''NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
223
0
"""simple docstring""" import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim ...
357
"""simple docstring""" import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2...
12
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, ...
267
import math lowerCAmelCase__ :Optional[int] = 1_0 lowerCAmelCase__ :Optional[Any] = 7 lowerCAmelCase__ :Union[str, Any] = BALLS_PER_COLOUR * NUM_COLOURS def lowerCAmelCase__ ( a__: int = 2_0 ) -> str: '''simple docstring''' _UpperCAmelCase ...
329
0
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class a ( a__ ): snake_case__ =...
370
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Dict = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctc...
309
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { '''configuration_graphormer''': ['''GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GraphormerConfig'''], } try: if n...
196
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test...
196
1
"""simple docstring""" import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging UpperCAmelCase__ : str = logging.get_log...
363
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ : int = logging.get_logger(__name__) UpperCAmelCase__ : Union[str, Any] = { 'vocab_file': 'vocab.j...
301
0
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def snake_case_ (_a : str ): UpperCAm...
34
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_...
174
0
def _a ( SCREAMING_SNAKE_CASE = 50_00_00_00 ): """simple docstring""" lowercase__ = set() lowercase__ = int((limit - 24) ** (1 / 2) ) lowercase__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for...
353
def _a ( SCREAMING_SNAKE_CASE = 10_00 ): """simple docstring""" return sum(e for e in range(3 , SCREAMING_SNAKE_CASE ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f"""{solution() = }""")
93
0
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __A =logging.get_logger(__name__) __A ={'''vocab_file''': ...
19
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() __A =logging....
19
1
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def __a ( lowerCAmelCase_ ...
367
def __a ( lowerCAmelCase_ : Dict ) -> Dict: '''simple docstring''' return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], ...
277
0
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelO...
113
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is...
113
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase : Dict ={ """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIV...
351
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common impo...
32
0
from maths.prime_check import is_prime def _SCREAMING_SNAKE_CASE ( a ) -> int: if not isinstance(a , a ): __A : Optional[Any] = F"""Input value of [number={number}] must be an integer""" raise TypeError(a ) if is_prime(a ) and is_prim...
280
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 ...uti...
280
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerToke...
145
def lowercase__ ( __snake_case : int ): '''simple docstring''' UpperCAmelCase_ : Tuple = [1] UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ : Tuple = 0, 0, 0 UpperCAmelCase_ : Union[str, Any] = ugly_...
145
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/xmod-base': 'https://huggingface.co/facebook/xmod-base/...
30
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bir...
12
0
"""simple docstring""" def _UpperCamelCase ( snake_case__ ) -> list[int]: if num <= 0: raise ValueError("Input must be a positive integer" ) __UpperCAmelCase : List[Any] = [True] * (num + 1) __UpperCAmelCase : Lis...
363
import logging import os from .state import PartialState class _snake_case ( logging.LoggerAdapter ): @staticmethod def _lowerCamelCase ( __lowerCamelCase: Any ) -> int: __UpperCAmelCase : str = PartialState() return no...
342
0
__UpperCamelCase : List[Any] = { 'joule': 1.0, 'kilojoule': 1000, 'megajoule': 100_0000, 'gigajoule': 10_0000_0000, 'wattsecond': 1.0, 'watthour': 3600, 'kilowatthour': 360_0000, 'newtonmeter': 1.0, 'calorie_nutr': 4186.8, 'kilocalorie_nutr': 418_6800...
182
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
0
from __future__ import annotations def __magic_name__ ( __lowerCAmelCase : str , __lowerCAmelCase : list[str] | None = None ) -> list[list[str]]: __lowerCamelCase = word_bank or [] # create a table __lowerCamelCase = len(__lowerCAmelCase ...
339
from datetime import datetime as dt import os from github import Github SCREAMING_SNAKE_CASE__ : Any = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __magic_name__ ( ) -> Any: ...
339
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def _lowercase ( lowercase__ ): __lowerCAmelCase : Optional[Any] = {} __lowerCAmelCase : Tuple = job['''started_at'''] __lowerCAmelCase : ...
275
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import ena...
275
1
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 SCREAMING_SNAKE_CASE :int = logging.get_logger(__...
361
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Union[str, Any] = { """BridgeTower/bridgetow...
60
0
"""simple docstring""" import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 10, """max_num_jobs"""...
109
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE...
93
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline _lowerCamelCase : Any = { '''n_samples''': 6_4, '''horizon''': 3_2, '''num_inference_steps''': 2_0, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does not...
191
import requests from bsa import BeautifulSoup def _a ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : dict ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = BeautifulSoup(requests.get(SCREAMING_SNAK...
191
1
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller __UpperCamelCase = 3 def lowercase (SCREAMING_SNAKE_CASE_ : int ) -> Dict: print('Generating primitive root of p' ) w...
113
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline a_ :List[Any] = logging.get_logger(__name__) @a...
277
0
__a: int = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __a: Optional[int] = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ): lowercase__ : Tuple = True lowercase__ : ...
357
'''simple docstring''' import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class UpperCAmelCase ( tf.keras.optimizers.schedules.LearningRateSc...
214
0