code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """google/mobilen...
177
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """microsoft/unispeech-large-1500h-cv""": ( """https://huggingface.co/microsoft/unispeech-large-1500h...
177
1
def lowercase__( A ): if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) snake_case__ : Optional[int] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 snake_case__ : Union[str, Any] = 1 ...
303
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 : List[Any] = { 'facebook/xmod-ba...
303
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase : Dict = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/...
4
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def __lowerCAmelCase ( lowercase : Optional[int] ...
178
0
from math import pow def UpperCamelCase ( _A : int , _A : int , _A : int , _A : int , _A : int , )-> tuple[int, int]: """simple docstring""" if current_sum == needed_sum: # If the sum of the powers...
232
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError("To use the rich extension, install rich with `pip install rich`")
232
1
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex _SCREAMING_SNAKE_CASE : Union[str, Any] = logging.getLogger(__name__) class _snake_case ...
400
'''simple docstring''' import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( Albe...
400
1
"""simple docstring""" from __future__ import annotations def lowercase__ ( lowercase_ ) -> int: """simple docstring""" _UpperCamelCase : Dict = len(lowercase_ ) // 2 # choose the middle 3 elements _UpperCamelCase : Dict = ls...
51
"""simple docstring""" lowerCamelCase__ = "\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/...
51
1
'''simple docstring''' def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _a ( _lowerCamelCase , _lowerCamelCase , _lo...
26
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput A : Any = 'scheduler_config.json' class __A( a ): snake_case_...
219
0
"""simple docstring""" from math import pi def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
194
"""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 = { 'configuration_roberta': ['ROBER...
194
1
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_o...
589
"""simple docstring""" from string import ascii_uppercase a__ : Any = {char: i for i, char in enumerate(ascii_uppercase)} a__ : str = dict(enumerate(ascii_uppercase)) def A__ ( __lowerCamelCase, __lowerCamelCase ): """simple docstring"...
589
1
"""simple docstring""" # Imports import numpy as np class _A : """simple docstring""" def __init__( self : Union[str, Any] , __UpperCAmelCase : Any=None , __UpperCAmelCase : str=None , ...
135
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { """facebook/s2t-small-librispeech-asr""": ( """https://huggingface.co/facebook/s2t-small-...
135
1
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def a__ ( UpperCamelCase_ : Optional[int], UpperCamelCase_ : bool = True, UpperCamelCase_ : float = math.inf, UpperCamelCase_ : float =...
467
'''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 __lowerCamelCase = logging.get_logger(_...
467
1
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 __SCREAMING_SNAKE_CASE : List[str] ...
713
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regr...
149
0
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFea...
106
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str: """simple docstring""" __A = """""" 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 _SCREAMING_SNAKE_CASE ...
637
0
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 OptionalDependencyN...
703
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @req...
154
0
"""simple docstring""" from __future__ import annotations import time snake_case = list[tuple[int, int]] snake_case = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, ...
103
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.set_...
20
0
'''simple docstring''' from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt...
187
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A...
187
1
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowerCAmelCase__ : int =argparse.ArgumentParser() parser.add_argument('--dump_path', default...
101
from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCamelCase_( __magic_name__ : str , __magic_name__ : str ): """simple docstring""" _lowerCAmelCase :Optional[int] = list(__magi...
687
0
def __lowerCamelCase(UpperCAmelCase__ : int = 1 , UpperCAmelCase__ : int = 1_0_0_0 ): SCREAMING_SNAKE_CASE = 1 SCREAMING_SNAKE_CASE = 0 for divide_by_number in range(UpperCAmelCase__ , digit + 1 ): SCREAMING_SNAKE_CASE = ...
721
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase : List[Any] = '''...
647
0
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow _snake_case = logging.getLogger() @unittest.skip("Temporarily disable the doc tests." ) @require_...
383
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow ...
383
1
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) snake_case__ : T...
719
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
655
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : int = {"""configuration_mmbt""": ["""MMBTConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
563
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) UpperCAmelCase : Union[str, Any] = logging.getLogger(__n...
563
1
import json import sys def __UpperCamelCase ( _A : Any , _A : Any ) ->Optional[Any]: """simple docstring""" with open(_A , encoding="""utf-8""" ) as f: lowerCamelCase_ =json.load(_A ) lowerCamelCase_ =["""<deta...
75
def __UpperCamelCase ( _A : str , _A : int ) ->str: """simple docstring""" lowerCamelCase_ =[[] for _ in range(_A )] lowerCamelCase_ =key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""...
75
1
"""simple docstring""" from typing import Any class a__ : def __init__( self : List[str] , UpperCamelCase_ : Any): """simple docstring""" __UpperCAmelCase : str = data __UpperCAmelCase : Optional[Any] = None ...
77
'''simple docstring''' def UpperCAmelCase ( UpperCAmelCase__ : int = 50): lowerCamelCase : List[Any] = [1] * (length + 1) for row_length in range(length + 1): for tile_length in range(2 , 5): for tile_start in range(row_length - t...
320
0
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require_sen...
264
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase_ ( lowercase: ndarray ) -> float: '''simple docstring''' return np.dot(lowercase , lowercase ) class __magic_name__ : """simple docstring...
264
1
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.log...
111
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is...
111
1
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSemanti...
718
"""simple docstring""" import json import os import tempfile import unittest import numpy as np from datasets import load_dataset 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 i...
22
0
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration _lowercase : List[str] =5_0000 _lowercase : str =5000 _lowercase , _lowercase : List[str] =os.path.split(__file__) _lowercase : Union[str, A...
364
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import (...
364
1
'''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, normalize, re...
702
'''simple docstring''' from __future__ import annotations def a__ ( lowerCAmelCase__ , lowerCAmelCase__ = None , lowerCAmelCase__ = None ) -> None: if start is None: UpperCAmelCase__ : List[Any] = 0 if end is None: Up...
312
0
'''simple docstring''' import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 A__ : str =0b1_0_1_1_0_0_1_1_1_1_...
207
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common impo...
207
1
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowercase ( _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' def is_in_circle(_SCREAMING_SNAKE_...
95
"""simple docstring""" import operator def lowercase ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : bool = False , _SCREAMING_SNAKE_CASE : list | None = None ): '''simple docstring''' _UpperCAmelCase = ...
95
1
def __snake_case ( __UpperCamelCase : List[Any] ): """simple docstring""" if collection == []: return [] # get some information about the collection A_ = len(__UpperCamelCase ) A_ = max(__UpperCamelCase ) A_ ...
86
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from...
86
1
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __SCRE...
714
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available()...
88
0
import math import qiskit def _SCREAMING_SNAKE_CASE ( lowercase : int = 1 , lowercase : int = 1 , lowercase : int = 1 ): '''simple docstring''' if ( isinstance(lowercase , lowercase ) or isinstance(low...
70
"""simple docstring""" def lowercase (_snake_case ) -> int: '''simple docstring''' __UpperCamelCase = len(_snake_case ) __UpperCamelCase = len(matrix[0] ) __UpperCamelCase = min(_snake_case ,_snake_case ) for row in range(_snake_case ...
505
0
"""simple docstring""" class SCREAMING_SNAKE_CASE__ : def __init__( self : str , SCREAMING_SNAKE_CASE_ : str = "" , SCREAMING_SNAKE_CASE_ : bool = False ): # Mapping from the first character of the prefix of the node lowerCamelCase__ ...
258
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __magic_name__ = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: ...
258
1
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
335
import numpy as np def __lowercase ( __lowerCAmelCase : np.ndarray , __lowerCAmelCase : float ): return np.where(vector > 0 , __lowerCAmelCase , (alpha * (np.exp(__lowerCAmelCase ) - 1)) ) if __name__ == "__main__": import doctest doct...
335
1
import os import sys import unittest __magic_name__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object...
314
from queue import PriorityQueue from typing import Any import numpy as np def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ,...
314
1
def __SCREAMING_SNAKE_CASE ( a__ : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __A : Optional[int] = sorted(string.lower() ) return len(a__ ) == len(set(a__ ...
17
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowercase__ ( __snake_case : Optional[Any] ): '''simple docstring''' if "model" in orig_key: UpperCAmelCase_ : Optional[int] = orig_key.replace('model....
406
0
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor ...
719
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: list[int] ): """simple docstring""" _lowerCAmelCase = [] if len(SCREAMING_SNAKE_CASE ) == 1: return [nums.copy()] for _ in range(len(SCREAMING_SNAKE_CASE ...
491
0
from math import ceil def __snake_case ( __UpperCamelCase : int = 1001 ): """simple docstring""" A_ = 1 for i in range(1 ,int(ceil(n / 2.0 ) ) ): A_ = 2 * i + 1 A_ = 2 * i A_ = ...
86
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor, ...
412
0
from collections import deque from .hash_table import HashTable class A_ ( __lowerCamelCase ): '''simple docstring''' def __init__( self , *snake_case , **snake_case ): super().__init__(*UpperCAmelCase__ , **UpperCAmelCase__ ) def SCREAMING_SNAKE_CASE__ ( self , s...
721
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = [[] for _ in range(__SCREAMING_SNAKE_CASE )] lowercase = key - 1 if key <= 0: raise ValueError('Height of grid can\'t be 0 or negative' ) if key == 1 or len(__SCREAM...
565
0
"""simple docstring""" from cva import destroyAllWindows, imread, imshow, waitKey def __magic_name__ ( UpperCamelCase : int ) -> int: a__ = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(__A ): for j in range(__A ...
273
'''simple docstring''' import operator as op def lowerCAmelCase_ ( __A : int ): '''simple docstring''' snake_case: List[Any] = [] snake_case: Optional[Any] = lambda __A , __A : int(x / y ) # noqa: E731 integer division opera...
329
0
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCamel...
107
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _lowerCamelCase ( unittest.TestCase ): def UpperCamelCase_ ( self ) -> str: SCREAMING_SNAKE_CASE__: List[Any]= [ '''safety_checker/pytorch_model.bin''', '...
107
1
from __future__ import annotations from collections.abc import Callable def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase, __UpperCamelCase, __UpperCamelCase = 100, ): SCREAMING_SNAKE_CASE__ =x_start SCREAMING_SNAKE_CASE__ =fnc(__UpperCamelC...
151
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () lowerCamelCase_ = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (trapmf(), gbel...
151
1
import pprint import requests _lowercase : Tuple = "https://zenquotes.io/api" def _lowerCAmelCase ( ) -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def _lowerCAmelCase ( ) -> list: """simple docstring""" ...
546
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 _UpperCamelCase : """simple docstring""" @property def _U...
546
1
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, B...
12
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase_ ( metaclass=__a ): lowerCAmelCase__ = ['torch', 'torchsde'] def __init__( self : Tuple , *_A : Any , **_A : Optional[Any] ...
75
0
import inspect import unittest from transformers import BitConfig 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 BackboneTesterMixin from ...test_con...
720
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput snake_case_ : Optional[Any] = '''scheduler_config.json''' class A__ ( UpperCamelCase__ ): Uppe...
191
0
'''simple docstring''' import enum import shutil import sys snake_case, snake_case = shutil.get_terminal_size() snake_case = {'''UP''': '''A''', '''DOWN''': '''B''', '''RIGHT''': '''C''', '''LEFT''': '''D'''} class SCREAMING_SNAKE_CASE ( enum.Enum ): """simple docstring""" ...
309
'''simple docstring''' import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: impor...
309
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging.set_...
522
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a : Any = {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP"...
522
1
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig...
386
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING...
237
0
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_avai...
273
'''simple docstring''' import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accele...
273
1
from cva import destroyAllWindows, imread, imshow, waitKey def lowerCamelCase__ (_UpperCAmelCase): # getting number of pixels in the image SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in r...
73
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_tim...
35
0
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case : def __init__( self :Union[str, Any] , _lowerCamelCase :int = 6 ): __SCREAMING_SNAKE_CASE : Node | None = None __SCREAMING_SNAKE_CASE : ...
401
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowerCAmelCase_ ( lowercase_ : di...
401
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ : Optional[Any] = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAIN...
589
"""simple docstring""" import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() a__ : List[Any] = log...
589
1
"""simple docstring""" import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class A_ ( pl.LightningModule ): def __init__( self : List[An...
714
"""simple docstring""" def _lowerCAmelCase ( __lowerCamelCase:int ): '''simple docstring''' __magic_name__ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
468
0
def lowercase__ ( A_: float , A_: float ) -> float: """simple docstring""" if density <= 0: raise ValueError("""Impossible fluid density""" ) if bulk_modulus <= 0: raise ValueError("""Impossible bulk modulus""" ) ...
68
'''simple docstring''' 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 __A ( a ): ...
161
0
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( ...
138
import numpy as np def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : np.ndarray , _SCREAMING_SNAKE_CASE : np.ndarray , _SCREAMING_SNAKE_CASE : float = 1E-12 , _SCREAMING_SNAKE_CASE : int = 100 , ): assert np.shape(_SCREAMING_SNAKE_CASE )[0] == n...
138
1
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) A = { ...
125
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( lowerCAmelCase__ ): '''simple docstring''' lowerCAmelCase__ : Dict = (PNDMScheduler,) ...
125
1
"""simple docstring""" def _lowercase ( __snake_case ) -> list[list[int]]: __lowerCAmelCase : str = [] if len(__snake_case ) == 1: return [nums.copy()] for _ in range(len(__snake_case ) ): __lowerCAmelCase : Union[str, Any] =...
615
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtraction...
615
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch...
511
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def A_ ( ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = ArgumentParser( description=( ...
511
1
"""simple docstring""" import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _UpperCamelCase ( unittest.TestCase ): """simple docstring""" def _UpperCAmelCase ( self : Optional[int]...
147
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_ ( lowerCamelCase : int ) -> bool: """simple docstring""" __magic_name__ : int = int(number**0.5 ) ret...
147
1
"""simple docstring""" import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_confi...
82
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ......
82
1
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 cached_property from ...test_toke...
716
# 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 applicab...
633
0
"""simple docstring""" from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class __lowercase ( _UpperCAmelCase): """simple docstring""" _A : str = CustomTokenizer pass
480
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
348
0
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lowerCAmelCase ( lowercase__ , unittest.TestCase ...
704
from __future__ import annotations import time a__ = list[tuple[int, int]] a__ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], ...
99
0
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _a : _lowercase : int _lowercase : Node | None = None _lowercase ...
43
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformer...
50
0
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
178
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def lowerCAmelCase_ ( _l...
178
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class lowerCAmelCase_ ( __A , __A ): '''simple docstring''' @register_to_config def __init__( self , *, __UpperCAmelCase = 4...
220
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__vers...
220
1
'''simple docstring''' import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import Threaded...
357
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __lowercase : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotA...
357
1
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :str , SCREAMING_SNAKE_CASE :Union[str, Any] ) -> str: # Checks if the entire collection has been sorted if len(SCREAMING_SNAKE_CASE ) <= 1 or n <= 1: return inse...
504
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> list[tuple[int, int]]: __lowercase , __lowercase = position __lowercase = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y -...
375
0
"""simple docstring""" from ... import PretrainedConfig UpperCamelCase_ : List[Any] = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class _lowercase ( lowerCAmelCase ): _a : Any = NEZHA_PRE...
497
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ : Optional[Any] = logging.get_logger(__n...
497
1
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"], "tokenization_xlm": ["XLMTokenizer"], } try: if not ...
475
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
657
0
"""simple docstring""" from __future__ import annotations def lowercase__ ( lowerCAmelCase__ : Union[str, Any] , lowerCAmelCase__ : Optional[int] = None ): '''simple docstring''' a__ : List[str] = word_bank or [] # create a table a__ : int = le...
712
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils impor...
251
0
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def _lowerCamelCase (__lowerCamelCase : list[list[float]] ) -> list[list[float]]: a__ = Decimal # Check if the provided matrix has 2 rows and 2 columns ...
489
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ ( __lowerCAmelCase ): lowerCAmelCase__ : Optional[int] = (UnCLIPScheduler,) def __a ( ...
489
1
'''simple docstring''' import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeache...
716
'''simple docstring''' import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowerCAmelCase__ : Dict = argparse.ArgumentParser() parser.add_argum...
502
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slow f...
167
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, TokenC...
167
1
snake_case_ : Tuple = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def SCREAMING_SNAKE_CASE_( a__): _SCREAMING_SNAKE_CASE =0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared ...
701
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full...
191
0
"""simple docstring""" def __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" if length <= 0 or not isinstance(UpperCamelCase__ , UpperCamelCase__ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(UpperCamelCase__ )] if __name...
657
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterM...
657
1
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_unordered, ...
708
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast 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 ...
308
0
'''simple docstring''' import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import Token...
50
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A__ ( __lowerCAmelCase : Any ): # This defines a "chinese character" as anything in the CJK Unicode block: ...
50
1
class _lowercase : '''simple docstring''' def __init__( self :Optional[int] , lowerCAmelCase__ :Tuple , lowerCAmelCase__ :Tuple , lowerCAmelCase__ :Optional[int] ) -> Dict: __SCREAMING_SNAKE_CASE : Optional[int] = None __SCREAMING_SNAK...
707
import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing import PolynomialFeatu...
260
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
104
'''simple docstring''' import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import...
286
0
import re def snake_case_ ( snake_case ) -> str: if len(re.findall('[ATCG]' , __UpperCamelCase ) ) != len(__UpperCamelCase ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) ) i...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # See all CANINE models at https://hu...
335
0
def UpperCamelCase ( snake_case__ : List[Any] ,snake_case__ : List[Any] ): '''simple docstring''' assert x is not None assert y is not None __snake_case :Optional[int] = len(_lowercase ) __snake_case :int = len...
455
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): def a_ ( self : Union[str, Any] , A__ : ...
150
0
import sys _UpperCAmelCase = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """66896648950445244523161...
70
def UpperCamelCase ( __lowercase : str ): '''simple docstring''' A_ : int = len(__lowercase ) A_ : List[Any] = sum(__lowercase ) A_ : List[str] = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(...
70
1
"""simple docstring""" A : Tuple = 8.3_144_598 def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("Molar mas...
636
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = False while is_sorted is False: # Until all the indices are traversed keep looping __lowerCAmelCase = True for i in range(0 , le...
636
1
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask A__ = logging.getLogger(__name__) class __UpperCamelCase ( SCREAMING_SNAKE_CASE ): def __init__( self: int , __UpperCa...
184
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__ = {"configuration_van": ["VAN_PRETRAINED_CONFIG_ARCHIVE_MAP", "VanConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAva...
184
1
from __future__ import annotations from collections.abc import Callable lowerCAmelCase_ = list[list[float | int]] def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase ) -> Matrix: """simple docstring""" snake_case_ : int = len...
60
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Accelerat...
271
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEG...
143
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, ...
143
1
'''simple docstring''' def __snake_case ( lowercase : str , lowercase : bool = False ): if not isinstance(lowercase_ , lowercase_ ): snake_case_ = f'''Expected string as input, found {type(lowercase_ )}''' raise ValueError(lowercase_ ) ...
508
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_availab...
536
0
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel __magic_name__ : List[Any] = False __magic_name__ : int = True __magic_name__ : List[str] = False ...
608
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 lowerCAmelCa...
608
1
"""simple docstring""" from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers im...
602
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __A : List[str] = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for...
602
1
import inspect import unittest class snake_case__ ( unittest.TestCase ): def UpperCAmelCase__ ( self : Any ): try: import diffusers # noqa: F401 except ImportError: assert False def Up...
303
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case__ ( UpperCamelCase_ ): _lowerCAmelCase...
303
1
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE = 299_792_458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = symbols("""ct x y...
554
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
554
1
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics f...
432
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
432
1
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer UpperCamelCase__ = logging.g...
227
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_pr...
207
0
'''simple docstring''' import os def lowercase ( ): """simple docstring""" _A : Dict = os.path.dirname(os.path.realpath(lowerCAmelCase)) _A : Any = os.path.join(lowerCAmelCase , '''triangle.txt''') with open(lowerCAmelCase) as f: ...
417
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Union[str, Any] = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegC...
417
1
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A_ : List[Any] =logging.get_logger(__name__) A_ : Option...
483
# 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 require...
483
1
"""simple docstring""" import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig __snake_case = { '''facebook/maskformer-swin-base-ade...
285
"""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 ImageProcessingSavingTestMixin, p...
285
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configur...
84
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
102
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case ( __UpperCAmelCase ): lowerCamelCase__ = '''SpeechT5FeatureExtractor''' lowerCamelCase__ = '''SpeechT5Tokenizer''' def __init__( self :List[Any] , _low...
710
"""simple docstring""" from __future__ import annotations _lowerCamelCase = 8.988e9 # units = N * m^s * C^-2 def lowerCAmelCase_ ( lowercase_ : float , lowercase_ : float , lowercase_ : float , lowercase_ : float ): '''simple doc...
401
0