code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def __lowerCamelCas...
241
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase__ = { """configuration_clip"""...
241
1
'''simple docstring''' import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_in...
351
'''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 UpperCAmelCase ...
187
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependen...
264
"""simple docstring""" import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolv...
290
0
import copy import re class _SCREAMING_SNAKE_CASE : lowerCAmelCase__ = 'hp' lowerCAmelCase__ = {} lowerCAmelCase__ = None @classmethod def SCREAMING_SNAKE_CASE_( cls , lowercase , lowercase ) -> Tuple: lowerCamelCase_ = prefix ...
47
from sklearn.metrics import recall_score import datasets __A =''' Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the false negatives. ''' __A =''' Arg...
47
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_a...
76
from typing import Any class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : Any ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE : int = data SCREAMING_SNAKE_CASE : int = None ...
76
1
"""simple docstring""" import os from collections.abc import Iterator def UpperCAmelCase__ ( lowerCAmelCase__ :str = "." ) -> str: '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCAmelCase__ ): lowercase = [d for d in dir_na...
359
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def UpperCAmelCase__ ( lowerCAmelCase__ :Union[str, Any] ) -> Dict: '''simple docstring''' if "img...
32
0
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def __a ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->int: """simple docstring""" A = ("""dense.weight""...
258
'''simple docstring''' import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unord...
258
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass lowercase_ = (3, 9, -11, 0, 7, 5, 1, -1) lowercase_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class A : """simple docstring...
361
def _snake_case( SCREAMING_SNAKE_CASE__ : int = 1000 ) -> int: '''simple docstring''' A__ = 3 A__ = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: res...
282
0
'''simple docstring''' import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipe...
28
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__ : List[str] = { """huggingface/infor...
224
0
from __future__ import annotations import numpy as np def _lowercase ( UpperCamelCase_ ) -> Optional[int]: '''simple docstring''' return np.maximum(0 , _A ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
355
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_...
169
0
def A ( _lowercase ): if n == 1 or not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): return 0 elif n == 2: return 1 else: SCREAMING_SNAKE_CASE : Union[str, Any] = [0, 1] for i in range(2 ,...
182
import pytest __UpperCAmelCase : Optional[Any] = "__dummy_dataset1__" __UpperCAmelCase : List[str] = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\":...
111
0
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file,...
258
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_...
258
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForS...
308
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_lowerCamelCase ) , ...
308
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ : Optional[int] = logging.get_logger(__name__) lowerCamelCase_ : Dict = { """bert-base-unc...
197
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ : Dict = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is_torch_ava...
197
1
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __magic_name__( lowerCamelCase, lowerCamelCase, lowerCamelCase = "x", lowerCamelCase = 1_0**-1_0, lowerCamelCase = 1, ): __lowerCAmelCase = symbols(lowerCamelCase) ...
174
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Optional[Any] = { """config...
174
1
def lowerCAmelCase_ (lowerCAmelCase__: Tuple = 1_0_0 ): """simple docstring""" UpperCAmelCase_: Optional[int] = (n * (n + 1) // 2) ** 2 UpperCAmelCase_: Optional[int] = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name...
358
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets a : Dict = datasets.logging.get_logger(__name__) a : Any = '\\n@InProceedings{moosavi2019minimum,\n ...
82
0
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_ut...
279
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowerCAmelCase_ = { '''tiny.en''': '''https://openaipublic.azureedge.net/main/whisper/models/d3dd57d3...
279
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A__ = logging.get_logger(__name__) A__ = { '''uw-madison/mra-base-512-4''': '''https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json''', } class a ( __l...
44
import argparse from collections import defaultdict def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> Optional[Any]: """simple docstring""" snake_case__ : Dict = f"""{file}_{clas...
44
1
'''simple docstring''' 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 ( ...
250
# Algorithm for the pigeonhole sorting def _UpperCAmelCase ( a__): '''simple docstring''' a_ : List[Any] = min(a__) # min() finds the minimum value a_ : List[str] = max(a__) # max() finds the maximum value a_ : str = max_val - min_val + 1 ...
248
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex...
364
'''simple docstring''' from collections.abc import Iterable from typing import Any class a__ : '''simple docstring''' def __init__( self , lowerCamelCase_ = None ) -> List[str]: lowerCAmelCase__ = value ...
228
0
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def snake_case_ ( __SCREAMING_SNAKE_CASE : Optional[int] , __SCREAMING_SNAKE_CASE : int=1 ): """simple docstring""...
93
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : Optional[int] = { 'facebook/mask2former-swin-small-coco-instance': ( 'https://huggingfa...
32
0
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def snake_case ...
253
"""simple docstring""" import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..ut...
253
1
def A (__A : int ) -> list: """simple docstring""" UpperCAmelCase_ = int(__A ) if n_element < 1: UpperCAmelCase_ = ValueError('''a should be a positive number''' ) raise my_error ...
51
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : int = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "Deber...
51
1
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def lowerCamelCase_ ( _a ): ...
211
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) lowerCamelCase = {'''configuration_beit''': ['''BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BeitConfig''', '''Bei...
211
1
from ..utils import DummyObject, requires_backends class A_ ( metaclass=_lowerCamelCase ): lowerCAmelCase__ = ["""flax"""] def __init__(self :List[str] , *_UpperCamelCase :int , **_UpperCamelCase :Dict )-> List[str]: requires_backends(self ...
117
from __future__ import annotations def _a ( lowerCamelCase: list[float] , lowerCamelCase: Tuple ) -> List[str]: '''simple docstring''' print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(lowerCamelCase ): ...
117
1
import argparse import os import re _UpperCAmelCase = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict _UpperCAmelCase = re.compile(r"""[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+Ord...
367
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() ...
192
0
"""simple docstring""" import socket def lowerCamelCase__ ( ) -> Optional[int]: lowerCamelCase_ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) lowerCamelCase_ = socket.gethostname() lowerCamelCase_ = ...
183
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : str = logging.get_logger(__name__) __lowerCAmelCase : Dict = {...
107
0
def _a ( ) -> Any: '''simple docstring''' for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def _a ( SCREAMING_SNAKE_CASE__ : Any ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Union[str, A...
361
class lowerCamelCase : """simple docstring""" def __init__( self : int, _UpperCAmelCase : Dict, _UpperCAmelCase : str ) -> Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CAS...
191
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 ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, )...
259
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging __SCREAMING_SNAKE_CASE : ...
31
0
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging lowerCAmelCase : List[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ...
251
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def A_( A : List[Any]): UpperCamelCase = [ 'encoder.version', 'decoder.version', ...
251
1
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_...
42
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, r...
82
0
import random def UpperCAmelCase ( a_, a_, a_ ): '''simple docstring''' lowerCamelCase : Union[str, Any] = a[left_index] lowerCamelCase : Tuple = left_index + 1 for j in range(left_index + 1, a_ ): if a[j] < pivot: ...
359
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowercase ( __UpperCAmelCase ): lowercase_ = ['image_processor', 'tokenizer'] lowercase_ = 'ChineseCLIPImageProcessor' lo...
205
0
'''simple docstring''' import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformer...
55
"""simple docstring""" from math import pow def _UpperCAmelCase ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , ) -> tuple[int, int]: if current_sum =...
288
0
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Optional[Any] = { '''snap-research/efficientformer-l1-300''': ( '''h...
218
import datasets from .evaluate import evaluate _SCREAMING_SNAKE_CASE : Union[str, Any] = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, bookt...
218
1
from __future__ import annotations def lowerCAmelCase_ ( __UpperCAmelCase: int , __UpperCAmelCase: int ) -> list[list[int]]: UpperCamelCase__ : list[list[int]] = [] create_all_state(1 , __UpperCAmelCase , __UpperCAmelCase , [] , __...
201
import random def lowerCAmelCase_ ( __UpperCAmelCase: list , __UpperCAmelCase: Optional[int] ) -> tuple: UpperCamelCase__ ,UpperCamelCase__ ,UpperCamelCase__ : List[Any] = [], [], [] for element in data: if element < pivot: ...
201
1
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cac...
352
"""simple docstring""" def a__ ( snake_case__ , snake_case__ ) -> int: return number | (1 << position) def a__ ( snake_case__ , snake_case__ ) -> int: return number & ~(1 << position) def a__ ( snake_case__ , snake_case__ ) -> int: return num...
168
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 lowercase ( A__ ): """simple docstring""" def __init__( self ...
97
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def lowercase__ ( __UpperCamelCase , __UpperCamelCase , ...
321
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _A = { """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], """tokenizatio...
369
"""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, precisi...
212
0
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging A__ = """\ """ A__ = """ Perplexity (PPL) is one of the most common metrics for evaluating language models. It ...
82
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
"""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/licens...
86
"""simple docstring""" import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_availabl...
86
1
'''simple docstring''' from __future__ import annotations _A : List[Any] ='''Muhammad Umer Farooq''' _A : Union[str, Any] ='''MIT''' _A : List[Any] ='''1.0.0''' _A : List[str] ='''Muhammad Umer Farooq''' _A : str ='''contact@muhammadu...
41
"""simple docstring""" from __future__ import annotations import math def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> list: '''simple docstring''' if len(__lowerCAmelCase ) != 2 or len(a[0] ) != 2 or len(__lowerCAmelCase ...
136
0
"""simple docstring""" from __future__ import annotations def lowercase ( A_ , A_ )-> list[str]: '''simple docstring''' if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes: raise ...
368
"""simple docstring""" import sys import turtle def lowercase ( A_ , A_ )-> tuple[float, float]: '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase ( A_ , A_ , A_ , A_ , ...
226
0
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class a : def __init__( self : Union[str, Any] ): _UpperCAmelCase = {} def lowerCAmelCase_ ( self : Optional[int] , __lowerCAmelCase ...
289
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ...
289
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, ...
158
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import...
158
1
def UpperCamelCase_( lowerCamelCase_ ) -> list: if len(lowerCamelCase_ ) < 2: return collection def circle_sort_util(lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> bool: _lowercase : Any = False if low == high: ...
21
'''simple docstring''' from ..utils import DummyObject, requires_backends class _lowerCamelCase ( metaclass=lowercase__ ): '''simple docstring''' A_ : Optional[Any] = ["""flax""", """transformers"""] def __init__( self : Union[str, Any] , *_A : ...
331
0
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration A: int = 5_0_0_0_0 A: List[Any] = 5_0_0_0 A , A: Tuple = os.path.split(__file__) A: Dict ...
351
"""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_available, loggin...
76
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''', '''tiiuae...
37
'''simple docstring''' 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 logging _lowerCAmelCase = logging.get_logger(__na...
37
1
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCAmelCase__ : Tuple = Lock() def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmel...
37
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
1
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diff...
312
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _a : """simple docstring""" @property def __A ...
312
1
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from tr...
366
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = '''▁''' lowerCAm...
121
0
'''simple docstring''' import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def _lowerCamelCase ( lowercase : Union[str, Any] , lowercase : int , lowerc...
63
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments ...
74
0
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.utils import logging ...
361
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __snake_case ( __UpperCamelCase : List[Any] ): """simple docstring""" if ( (cp >= 0X4_E_0_0 and cp <= 0X9_F_F_F) or (cp >= 0X3_4_...
329
0
from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _A : np.ndarray , _A : tuple[int, int] , _A : tuple[int, int] , _A : bool , ) ->tuple[float | int, list[tuple[int, int]]]: """simple docstring""" lowerCamelCase_ , lowerCamelCase...
154
# 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 # # Unless required by applica...
154
1
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffuse...
368
"""simple docstring""" import argparse import os import re import packaging.version UpperCAmelCase_ : Any = """examples/""" UpperCAmelCase_ : Optional[int] = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check...
318
0
'''simple docstring''' from typing import TYPE_CHECKING from ..utils import _LazyModule __UpperCAmelCase = { """config""": [ """EXTERNAL_DATA_FORMAT_SIZE_LIMIT""", """OnnxConfig""", """OnnxConfigWithPast""", """OnnxSeq2SeqConfigWithPast""", """PatchingSp...
323
'''simple docstring''' from __future__ import annotations __UpperCAmelCase = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], "...
323
1
def A ( _UpperCAmelCase : int ) -> "list[int]": '''simple docstring''' if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) _UpperCAmelCase = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 _UpperCAmelCase =...
290
UpperCAmelCase__ = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def A ( _UpperCAmelCase : dict , _UpperCAmelCase : Optional[int] , _Upper...
290
1
'''simple docstring''' def _a( UpperCamelCase__ : List[str] ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any =len(__UpperCAmelCase ) for _ in range(__UpperCAmelCase ): for i in range(_ % 2, arr_size -...
152
"""simple docstring""" __A = [ (1_0_0_0, "M"), (9_0_0, "CM"), (5_0_0, "D"), (4_0_0, "CD"), (1_0_0, "C"), (9_0, "XC"), (5_0, "L"), (4_0, "XL"), (1_0, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) ->...
177
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowerCAmelCase : Tuple =logging.get_logger(__name__) def UpperCAmelCase_ ( __lowerCamelCase : Union[tf.Tensor, np.ndarray] ): if isinstance(__low...
353
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int | float | str ): try: lowercase_ :Optional[int] = float(__lowerCamelCase ) except ValueError: raise ValueError("Please enter a valid number" ) lowercase_ :Dict = ...
147
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHI...
249
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
1
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets __lowercase = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and Singh, Amanpreet and...
105
from __future__ import annotations def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ): '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 valu...
105
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_ch...
182
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : List[str] ={ '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''',...
53
0
def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase ): print("\nThe shortest path matrix using Floyd Warshall algorithm\n" ) for i in range(__lowerCamelCase ): for j in range(__lowerCamelCase ): if dist[i][j] != float("inf" ): print(int...
325
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import ...
325
1
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from tra...
32
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": a_ = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer Learned' ' Distillatio...
175
0
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase_( a__ , a__ , a__ ): """simple docstring""" SCREAMING_SNAKE_CASE : int ...
19
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar a__ : Any = TypeVar('''T''') def UpperCAmelCase_( a__ ): """simple docstring""" return (position - 1) // 2 def UpperCAmelCase_( a__ ): """simple docs...
19
1
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import...
75
"""simple docstring""" from __future__ import annotations class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: '''simple docstring''' UpperCAmelCase : Any = data UpperCAmelCase : Node | None = None UpperCAmelCase : ...
109
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, sk...
370
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase__ : Union[str, Any] = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_ber...
301
0
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class lowerCamelCase (_snake_case ): '''...
29
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess...
29
1
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, ImageInp...
75
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models...
75
1
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class _snake_case ( __snake_case ): '''simple docstring''' def __init__( self: int ,*lowerCamelCase_: List[s...
345
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging UpperC...
345
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch,...
52
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging lowerCAmelCase__ ...
52
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusion...
293
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->bool: """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
293
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A : Tuple = { "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } try: if not is_tokenizers_av...
305
from ....utils import logging A : List[str] = logging.get_logger(__name__) class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self : List[str] , __magic_name__ : Optional[Any] , __magic_name__ : Any=None ...
305
1
'''simple docstring''' import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer snake_case_ : ...
83
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( FlaxForce...
186
0
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before token...
362
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _A = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ' Distillation' ) ) pars...
117
0
"""simple docstring""" import os import pytest from attr import dataclass lowerCAmelCase__ : Any = 'us-east-1' # defaults region @dataclass class snake_case : """simple docstring""" snake_case__ = 42 snake_case__ = "arn:aws:iam::558105141721:role/sagemak...
98
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case : List[Any] = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['BioGptToken...
284
0
from datetime import datetime import requests def _lowercase ( _UpperCAmelCase ) -> bytes: lowerCamelCase ="""https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" lowerCamelCase =requests.get(base_url + url ).json()[0]["""urls"""][0]["""src"""] return re...
362
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 UpperCAmelCase__ : List[Any] =logging.get_logger(_...
262
0
'''simple docstring''' def __snake_case ( ): lowerCamelCase_ = [] lowerCamelCase_ = 1 while len(UpperCAmelCase_ ) < 1E6: constant.append(str(UpperCAmelCase_ ) ) i += 1 lowerCamelCase_ = "".join(UpperCAmelCase_ ) return ( int(constant[0] ) * int(...
55
'''simple docstring''' from __future__ import annotations def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = 2 lowerCamelCase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(UpperCAmelCase_ ) if n > 1: fac...
55
1
'''simple docstring''' import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from...
170
'''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, ...
170
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer __A =logging.get_logger(__name__) __A ={'''vocab_file''': '''vocab.txt'...
19
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_mod...
19
1
'''simple docstring''' from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) _lowercase = 299792458 # Symbols _lowercase , _lowercase , _lowercase , _lowercase = symbols("""ct x y z""") def A (__lowerCamelCase :float ): ...
358
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", ...
229
0
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from tr...
208
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowercase__ : Any = { '''tiny.en''': '''https://openaipublic.azureedge.net/main/whisper/model...
338
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, norm...
354
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ : str = logging.get_logger(__name__) lowerCamel...
215
0
def UpperCamelCase ( _A, _A, _A, _A, _A ): """simple docstring""" if index == number_of_items: return 0 __magic_name__ : Union[str, Any] = 0 __magic_name__ : str = 0 __magic_name__ : Optional[int...
342
import collections import inspect import unittest from transformers import FocalNetConfig 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_backbone_common import Backbone...
342
1
import logging import os from .state import PartialState class UpperCAmelCase ( logging.LoggerAdapter ): '''simple docstring''' @staticmethod def lowerCAmelCase_ ( lowercase ): """simple docstring""" A_ : List[Any] ...
192
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer _UpperCAmelCase = logging.get_logger(__name__) _Uppe...
192
1
"""simple docstring""" import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def _A ( *UpperCamelCase_ : List[Any]) -> List[str]: '''simple docstring''' if not isinstance(UpperCamelCase_, UpperCamelCase_): __lowerca...
17
"""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 lowerCamelCase_ = logging.get_logger(__name__) lowerCa...
191
0
"""simple docstring""" from math import factorial, radians def UpperCamelCase_ ( lowerCAmelCase__ : float , lowerCAmelCase__ : int = 18 , lowerCAmelCase__ : int = 10 ) -> float: """simple docstring""" lowerCAmelCase_ ...
368
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_ ( lowerCAmelCase__ : int ) -> bool: """simple docstring""" lowerCAmelCase_ : int = int(num...
289
0
"""simple docstring""" def snake_case_ ( A_ : int ): '''simple docstring''' if num < 0: return False _lowerCamelCase : int = num _lowerCamelCase : int = 0 while num > 0: _lowerCamelCase ...
72
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin lowerCam...
199
0
"""simple docstring""" def __lowerCamelCase ( a_ : int ) -> list[int]: if num <= 0: raise ValueError('''Input must be a positive integer''' ) __SCREAMING_SNAKE_CASE :Dict = [True] * (num + 1) __SCREAMING_SNAKE_CAS...
239
"""simple docstring""" def __lowerCamelCase ( a_ : Union[str, Any] , a_ : Optional[Any] ) -> Union[str, Any]: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __lowerCamelCase ( a_ : Optional[int] ,...
239
1
def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> int: while b: lowercase : Optional[Any] = b, a % b return a def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> int: return a if b ==...
20
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 __UpperCAmelCase =...
119
0
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK...
242
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase ={ 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTConfig', 'GroupViTOnnxCo...
242
1
import math def UpperCAmelCase__ (): """simple docstring""" snake_case = input('''Enter message: ''' ) snake_case = int(input(F'''Enter key [2-{len(UpperCamelCase_ ) - 1}]: ''' ) ) snake_case = input('''Encryption/Decryption [e/d]: ''' ...
127
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached...
127
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __snake_case ( _SCREAMING_SNAKE_...
353
'''simple docstring''' import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers ...
89
0
'''simple docstring''' def lowercase__ ( __lowercase : list[int] ) -> int: """simple docstring""" if not numbers: return 0 if not isinstance(__lowercase , (list, tuple) ) or not all( isinstance(__lowercase , __lowercase ...
53
'''simple docstring''' import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules...
53
1
"""simple docstring""" import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : int = logging.get_logger(__na...
369
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mod...
289
0
'''simple docstring''' import math class __a : def UpperCAmelCase__ ( self : List[str] , __magic_name__ : list[list[float]] , __magic_name__ : list[int] ) -> int: """simple docstring""" UpperCAmelCase_...
125
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class __a : def __init__( self : int , __magic_name__ : int , __magic_name__ : MutableSequence[float] ) -> None: ""...
125
1
"""simple docstring""" __A = """ # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git """ __A = [{"""type""": """code""", """content""": INSTALL_CONTENT}] __A ...
254
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule __A = {"""processing_wav2vec2_with_lm""": ["""Wav2Vec2ProcessorWithLM"""]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys __A = _Lazy...
254
1
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 ...utils import logg...
339
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo a_ :Any = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and Mi...
277
0
"""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_sentencepiec...
352
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): def __init__( self , *__UpperCAmelCase , **__Uppe...
303
0
class lowercase__ : def __init__( self : List[str] , UpperCAmelCase_ : List[str] ): # we need a list not a string, so do something to change the type SCREAMING_SNAKE_CASE__ = arr.split(',' ) def A_ ( self : Tuple ): ...
176
import os def _lowercase ( ) -> List[str]: '''simple docstring''' with open(os.path.dirname(UpperCamelCase_ ) + '/p022_names.txt' ) as file: SCREAMING_SNAKE_CASE__ = str(file.readlines()[0] ) SCREAMING_SNAKE_CASE__ = names.replace('"' ...
176
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def a( A : Optional[Any] ) -> Tuple: """sim...
361
# using dfs for finding eulerian path traversal def a( A : int , A : Optional[Any] , A : Any , A : Optional[int]=None ) -> List[str]: """simple docstring""" a = (path or []) + [u] for v in graph[u]: if visited_edge[u][v] is False: ...
71
0