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''' import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel...
501
'''simple docstring''' from collections.abc import Callable def __snake_case (__UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): """simple docstring""" lowerCamelCase_ : float = a lowerCamelCase_ : float = b if function(__UpperCAmelCase...
501
1
def lowerCamelCase( a__): return " ".join( ''''''.join(word[::-1]) if len(a__) > 4 else word for word in sentence.split()) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('''Hey wollef sroirraw'''))
191
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_u...
191
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowercase_ ( _UpperCamelCase , _UpperCamelCase=None ): '''simple docstring''' __lowercase = None if token is not None: __...
639
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandin...
110
0
'''simple docstring''' import math import random def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowerCamelCase__ = 0.02 def __lowerCAmel...
40
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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 ...
40
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=__snake_case ): """simple docstring""" __snake_case = ['onnx'] def __init__( self , *_lowercase , **_lowercase ) -> List[Any]: ...
434
def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): _validate_point(__lowerCamelCase ) _validate_point(__lowerCamelCase ) if len(__lowerCamelCase ) != len(__lowerCamelCase ): raise ValueError('Both points must be in the same n-dimensional space' ) return ...
559
0
import socket def a__ ( ): '''simple docstring''' __magic_name__ = socket.socket(socket.AF_INET, socket.SOCK_STREAM ) __magic_name__ = socket.gethostname() __magic_name__ = 12312 sock.connect((host, port) ) sock.send(b"""Hello s...
702
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase : List[str] = { 'configuration_canine': ['CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CanineConfig'], 'tokenization_canine': ['Cani...
76
0
'''simple docstring''' from collections.abc import Sequence from queue import Queue class lowercase_ : """simple docstring""" def __init__( self : Tuple, UpperCamelCase__ : Any, UpperCamelCase__ : List[Any], UpperCamelCase__ : Optional[int], UpperCamelCa...
107
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer UpperCAmelCase =logging.get_logge...
617
0
import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib __UpperCamelCase : Any = { ...
34
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __UpperCamelCase : str = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classification...
34
1
"""simple docstring""" import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.uti...
426
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''facebook/xglm-564M''': '''https://huggingface.co/facebook/xglm-564M/resolve/main/config.json''', ...
426
1
from __future__ import annotations from cmath import sqrt def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> tuple[complex, complex]: if a == 0: raise ValueError('Coefficient \'a\' must not be zero.' ) __lowerCamelCase ...
337
import argparse import json import subprocess def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> Tuple: __lowerCamelCase : List[str] = [] __lowerCamelCase : List[str] = ( F"curl -H \"Accept: application/v...
337
1
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformer...
18
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets UpperCamelCase__: str = "\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchm...
127
0
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 numpy as np import tensorflow as tf from transformers import TFXL...
707
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models...
369
0
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> list: SCREAMING_SNAKE_CASE__ : List[str] = int(__lowerCAmelCase ) if n_element < 1: SCREAMING_SNAKE_CASE__ : Tuple = ValueError("""a should be a positive number""" ) ...
680
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logg...
680
1
import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel lowercase_ : Any = lo...
652
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels lowercase_ : Optional[int] = object() # For specifying empty leaf dict `{}` lowercase_ : List[Any] = ...
652
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path __A : Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa...
343
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import M...
343
1
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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_co...
709
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 BackboneTester...
400
0
"""simple docstring""" import sys import turtle def lowerCAmelCase_ ( UpperCamelCase__ : tuple[float, float] , UpperCamelCase__ : tuple[float, float] ): """simple docstring""" return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowerCAmelCase_ ...
616
"""simple docstring""" def lowerCAmelCase_ ( UpperCamelCase__ : Union[str, Any] , UpperCamelCase__ : Union[str, Any] , UpperCamelCase__ : int ): """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation...
616
1
"""simple docstring""" import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient A__ : List[str] = WebClient(token=os.environ['CI_SLACK_BOT_TOKEN']) def _snake_case ...
244
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import D...
244
1
from __future__ import annotations def lowerCamelCase__ ( __lowerCamelCase : list[float] ): if len(__lowerCamelCase ) < 2: raise ValueError("""Monogons and Digons are not polygons in the Euclidean space""" ) if any(i <= 0 for i in nums ): r...
63
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class a : """simple docstring""" a : int a : Node | None = ...
63
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = { '''configuration_mask2former''': [ '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Mask2Fo...
667
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: assert ( isinstance(UpperCAmelCase__, UpperCAmelCase__ ) and number_of_steps > 0 ), F'''number_of_steps needs to be positive integer, your input {number_of_steps}''' if number_...
667
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def __A ( a_ :BertModel , a_ :str , a_ :str) -> str: __a : List[str] = ('''dense.weigh...
52
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Tuple = logging.get_logger(__name__) _a : Optional[int] = { 'xlm-mlm-en-204...
213
0
from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=A_ ): """simple docstring""" UpperCAmelCase__ : str = ["torch", "torchsde"] def __init__( self , *A_ , **A_ ) -> Dict: requires_backen...
682
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_util...
682
1
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class lowercase_ : """simple docstring""" def __init__( self : Optional[int] ,lowercase__ : list[tuple[float, float]] ): __lowercase = list_of_points # D...
41
'''simple docstring''' import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to...
41
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase ...
720
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_...
152
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dataclasses import ...
504
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[list[float]] ) -> list[list[float]]: __lowerCAmelCase : list[list[float]] = [] for data in source_data: for i, el in enumerate(SCREAMING_SNAKE_CASE ): if len(SCREAMING_SNAKE_CASE ) < i + 1: da...
504
1
def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase=False ): '''simple docstring''' if isinstance(_UpperCamelCase , _UpperCamelCase ) and isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = len(set_a.intersection(_UpperC...
527
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from...
527
1
from ....utils import logging a_ : str = logging.get_logger(__name__) class lowerCamelCase__ ( lowercase_): """simple docstring""" def __init__(self , __a , __a=None , __a=20_48 ): '''simple docstring''' ...
623
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _lowerCAmelCase ( lowercase_ ): """simple docstring""" _lowercase : Optional[int] = '''''' _lowercase : str = ...
654
0
'''simple docstring''' import requests from bsa import BeautifulSoup def A (__A : Union[str, Any] = "AAPL" ) -> Union[str, Any]: """simple docstring""" UpperCAmelCase_ = F"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" ...
701
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device snake_case_ : Tuple = False class __snake_case ( unittest.Test...
169
0
'''simple docstring''' import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configu...
8
'''simple docstring''' from ...configuration_utils import PretrainedConfig lowercase__ : Any = { '''google/tapas-base-finetuned-sqa''': ( '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json''' ), '''google/tapas-base-fi...
8
1
def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = len(lowerCamelCase ) __lowercase = sum(lowerCamelCase ) __lowercase = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n + 1 ): ...
711
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import loggi...
53
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __lowercase ( metaclass=UpperCamelCase_ ): _a = ["""flax""", """transformers"""] def __init__( self , *UpperCamelCase , **UpperCamelCase ) -> List[str...
539
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
680
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def A__ ( __A , __A , __A = False ): '''simple docstring''' if radian_mode: return [magnitude * cos(__A ), magnitude * sin(__A...
704
lowerCAmelCase : Tuple =0 # The first color of the flag. lowerCAmelCase : Union[str, Any] =1 # The second color of the flag. lowerCAmelCase : Any =2 # The third color of the flag. lowerCAmelCase : List[str] =(red, white, blue) def A__ ( __A...
15
0
'''simple docstring''' import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def UpperCAmelCase__ ( UpperCAmelCase_ : Union[str, Any] ) -> List[Any]: def wrapper(*UpperCAmelCase_ ...
13
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = {'v...
321
0
"""simple docstring""" import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging...
183
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( SCREAMING_SNAKE_CASE_ ): @staticmethod @abstractmethod def a_ ( lowercase_ ) -> Optional[Any]: raise NotIm...
183
1
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 con...
612
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { "google/pix2struct-textcaps-base": ( "https://huggingface.co/google/pix2struct-textcaps-ba...
612
1
from ..utils import DummyObject, requires_backends class __UpperCAmelCase ( metaclass=snake_case__ ): """simple docstring""" lowercase = ["""onnx"""] def __init__( self , *SCREAMING_SNAKE_CASE , **SCREAMING_SNAK...
713
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : Tuple = logging.get_logger(__name__) __a : List[str] = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", ...
414
0
'''simple docstring''' def lowerCAmelCase (__A , __A): """simple docstring""" while b: _a , _a = b, a % b return a def lowerCAmelCase (__A , __A): """simple docstring""" return a if b == 0 else euclidean_gcd_recursiv...
11
'''simple docstring''' def lowerCAmelCase (__A): """simple docstring""" return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''')) def lowerCAmelCase (__A): """simple docstring""" _a = credit_card_number _a ...
11
1
"""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_modeling_common import ModelT...
709
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transf...
623
0
from __future__ import annotations def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> int: '''simple docstring''' if len(_lowerCAmelCase ) < k or k < 0: raise ValueError("Invalid Input" ) __snake_case = ...
371
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ) -> Tuple: '''simple docstring''' import os as original_os from os import path as original_path from os impor...
371
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A : List[Any] = logging.get_logger(__name__) A : List[str] = { "kssteven/iber...
282
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sag...
282
1
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __lowercase ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = False ) -> Optional[Any]: '''simple docstring''' if radian_mode: return [m...
321
'''simple docstring''' import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from ...
152
0
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_ ...
262
def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = False ) -> bool: if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 1_0 not in (1, 3, 7, 9): # can quickly check last digit return False if n > 3_3_1_7_0_4_4_0_6_4_6_7...
262
1
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase , UpperCamelCase ) -> str: """simple docstring""" __UpperCAmelCase : list[list[str]] = [[] for _ in range(UpperCamelCase )] __UpperCAmelCase : Union[str, Any] ...
77
from pathlib import Path import fire def lowerCAmelCase_ ( lowercase: str , lowercase: str , lowercase: int ) -> int: '''simple docstring''' _UpperCamelCase: Any = Path(lowercase ) _UpperCamelCase: int = Path(lowercase ) dest_dir.mkdir(exist_o...
271
0
"""simple docstring""" def lowerCAmelCase_( lowercase_ : str , lowercase_ : str ) -> bool: _lowerCamelCase = len(lowercase_ ) _lowerCamelCase = len(lowercase_ ) _lowerCamelCase = [[False for _ in range(m + 1 ...
623
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transf...
623
1
'''simple docstring''' import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename a_ : Optional[Any] = """http:...
676
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import B...
676
1
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { 'CarlCochet/trajectory-transformer-halfcheetah-medium-v2': ( 'https://huggingface.co/CarlCochet/traj...
706
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCamelCase ( _A , _A , _A = 1 / sqrt(2 ) ) -> IIRFilter: lowercase : Optional[int] = tau * frequency / samplerate lowercase ...
348
0
"""simple docstring""" class UpperCamelCase_ (__A ): pass class UpperCamelCase_ (__A ): pass class UpperCamelCase_ : def __init__( self : List[str] ) -> Tuple: UpperCAmelCase_ : int = [ [], [], [], ] def _SCR...
95
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 : str = logging.get_logger(_...
511
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets snake_case : Dict = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, authors={Xu, ...
718
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : int = logging.get_logger(__name__) _UpperCAmelCase : int = { """facebook/timesformer""": """https://huggingface.co/facebook/timesformer/resolve/main/config.json""", } class...
683
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unle...
683
1
'''simple docstring''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
701
'''simple docstring''' from statistics import mean import numpy as np def __lowercase (_lowercase, _lowercase, _lowercase, _lowercase ) -> list: """simple docstring""" __lowerCamelCase : str = 0 # Number of processes finished __lowerCamelC...
483
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_c...
274
'''simple docstring''' import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, ...
274
1
"""simple docstring""" def lowercase ( a__ : Union[str, Any] ) -> Union[str, Any]: _UpperCamelCase = [0] * len(a__ ) _UpperCamelCase = [] _UpperCamelCase = [1] * len(a__ ) for values in graph.values(): for i in values: indegree[i] += 1 ...
342
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": UpperCAmelCase = input("""Enter image url: """).strip() print(F'''Downloading image from {url} ...''') UpperCAmelCase = BeautifulSoup(requests.get(url).content, ...
342
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ :Any = {"""configuration_xlnet""": ["""XLNE...
355
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> list: """simple docstring""" if len(lowercase_ ) <= 1: return [tuple(lowercase_ )] A__ = [] def generate(lowercase_ , lowercase_ ): if k == 1: res.append...
87
0
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/config.json...
403
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 _A = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE ( ) ...
403
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ : Dict = { 'configuration_rembert': ['REM...
98
from collections.abc import Callable import numpy as np def lowerCamelCase_ ( lowerCAmelCase__ : Callable , lowerCAmelCase__ : float , lowerCAmelCase__ : float , lowerCAmelCase__ : float , lowerCAmelCase__ : float ) -> np.array: '''simple docstring''' A ...
106
0
"""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 ModelTest...
713
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def lowerCAmelCase_( lowercase_ : float , lowercase_ : float , lowercase_ : float ) -> dict[str, float]: if (resistance, reactance, impedance).count(0 )...
623
0
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils ...
68
from torch import nn class __lowerCAmelCase ( nn.Module ): """simple docstring""" def __init__( self : Optional[int] , _snake_case : List[Any] , _snake_case : Tuple ): super().__init__() __lower...
509
0
from math import isqrt def _A ( __snake_case :int ) -> Optional[Any]: """simple docstring""" __SCREAMING_SNAKE_CASE = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in ra...
710
from typing import List import numpy as np def _A ( __snake_case :dict ) -> int: """simple docstring""" __SCREAMING_SNAKE_CASE = {key: len(__snake_case ) for key, value in gen_kwargs.items() if isinstance(__snake_case , __snake_case ...
214
0
"""simple docstring""" import sys def __lowerCamelCase ( __UpperCamelCase ) -> Union[str, Any]: """simple docstring""" lowerCAmelCase_ : int = len(__UpperCamelCase ) lowerCAmelCase_ : List[Any] = [[0 for x in range(__UpperCamelCase )] f...
610
"""simple docstring""" # Lint as: python3 import itertools import os import re lowercase__ = re.compile(r"""([A-Z]+)([A-Z][a-z])""") lowercase__ = re.compile(r"""([a-z\d])([A-Z])""") lowercase__ = re.compile(r"""(?<!_)_(?!_)""") lowercase__ = re.compile(r"""(_{2,})""") lowerc...
610
1
'''simple docstring''' from typing import Any class UpperCAmelCase : '''simple docstring''' def __init__( self , lowercase__ ) -> Dict: SCREAMING_SNAKE_CASE : Optional[int] = data SCREAMING_SNAKE_CASE ...
179
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class UpperC...
179
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case = { """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ConvBertConfig""...
62
'''simple docstring''' import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available...
596
0
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 ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrFor...
711
'''simple docstring''' def lowerCAmelCase__ ( UpperCAmelCase ): """simple docstring""" if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(UpperCAmelCase , UpperCAmelCase ): ...
172
0
from __future__ import annotations def lowerCamelCase_ ( _lowercase ) -> bool: __A : str = len(_lowercase ) # We need to create solution object to save path. __A : Union[str, Any] = [[0 for _ in range(_lowercase )] for _ in range(_lowe...
520
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 SequenceFeatureExtractionTestMixin if is_speech_available(): ...
520
1
def a__ ( a ) -> str: return "".join([hex(a )[2:].zfill(2 ).upper() for byte in list(a )] ) def a__ ( a ) -> bytes: # Check data validity, following RFC3548 # https://www.ietf.org/rfc/rfc3548.txt if (len(a ) % 2) != 0: ...
236
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _lowerCAmelCase = logging.get_logger(__name__) de...
236
1
'''simple docstring''' def lowerCAmelCase__ ( ): _A : Dict = 0 for i in range(1 ,1001 ): total += i**i return str(lowerCamelCase )[-10:] if __name__ == "__main__": print(solution())
128
'''simple docstring''' 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(a_ ) ...
128
1
import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() UpperCamelCase__ : Tuple = ...
486
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( AutoCo...
486
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICE...
525
def _SCREAMING_SNAKE_CASE ( a ) -> list: if len(a ) <= 1: return lst __A : Any = 1 while i < len(a ): if lst[i - 1] <= lst[i]: i += 1 else: __A , __A : str = lst[i]...
239
0
"""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, ) lowercase__ : List[...
485
"""simple docstring""" import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def __lowercase ( _a , _a , _a ): snake_case_ : Tuple = AutoConfig.from_pretrained(_a ) snake_case_ : Tuple = FlaxAutoModelF...
485
1
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowercase_ = get_tests_dir('fixtures/test_sentencepiece_with_bytefallback.model') ...
562
lowercase_ = 9.80665 def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = g ) -> float: if fluid_density <= 0: raise ValueError('Impossible fluid density' ) if volume < 0: raise ValueError('Impossible Object vol...
562
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def SCREAMING_SNAKE_CASE ( snake_case, snake_case, snake_case): __snake_case = ('''dense.weight''', '''attention.se...
93
"""simple docstring""" def SCREAMING_SNAKE_CASE ( snake_case): return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def SCREAMING_SNAKE_CASE ( snake_case): __snake_case = 0 __snake_case = number while duplicate > 0: ...
93
1
"""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/LI...
65
'''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...
138
0
from __future__ import annotations import requests __SCREAMING_SNAKE_CASE = set( """approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categorie...
716
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 fro...
17
0
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class _A ( snake_case ): '''simple docstring''' __lowerCamelCase : List[str] = CustomTokenizer pass
36
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, StableDiffusionXLImgaImgPipeline, UNeta...
122
0
'''simple docstring''' import qiskit def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : int ,_UpperCAmelCase : int ) -> qiskit.result.counts.Counts: _a : Union[str, Any] =qiskit.Aer.get_backend("""aer_simulator""" ) # Create...
506
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : str ,_UpperCAmelCase : str = " " ) -> list: _a : int =[] _a : Tuple =0 for index, char in enumerate(_UpperCAmelCase ): ...
506
1
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE ( snake_case__ ): snake_case__ = (IPNDMScheduler,) snake_case__ = ...
466
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 loa...
364
0
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class SCREAMING_SNAKE_CASE_ ( __SCREAMING_SNAKE_CA...
705
import re def _SCREAMING_SNAKE_CASE ( snake_case_ : str ): __magic_name__ = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(snake_case_ , snake_case_ ) ) if __name__ == "__main__": a_ : ...
678
0
"""simple docstring""" def snake_case ( A__ ): return "".join(chr(ord(A__ ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
95
import requests from bsa import BeautifulSoup def __lowerCamelCase ( A__ : str = "https://www.worldometers.info/coronavirus" ) -> dict: lowerCamelCase_ : List[str] = BeautifulSoup(requests.get(A__ ).text , """html.parser""" ) lowerCamelCase_ : Tuple ...
278
0
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def SCREAMING_SNAKE_CASE( __UpperCamelCase = "laptop" ) -> str: a__ : List[str] = F'https://www.amazon.in/laptop/s?k={product}' a__ : int = { 'User-A...
716
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Tra...
207
0
'''simple docstring''' import qiskit def __snake_case ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ): lowerCamelCase_ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register lowerCamelCase_ = qiskit.QuantumCirc...
675
'''simple docstring''' from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge a_ : Any = [ """Prosecutor: \"No videos were used in the crash investigation\" German paper...
675
1
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowercase ( A_ )->...
708
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _A ( _a ): """simple docstring""" UpperCAmelCase : Any = (IPNDMScheduler,) ...
135
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _UpperCamelCase ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase = 100 , ) -> float: """simple docstring""" __UpperC...
77
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
77
1
'''simple docstring''' from pathlib import Path import numpy as np from PIL import Image def UpperCamelCase ( lowercase_ : np.ndarray ) -> np.ndarray: '''simple docstring''' lowercase , lowercase , lowercase =rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return ...
720
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( IM...
145
0
'''simple docstring''' import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanv...
26
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = { '''configuration_electra''': ['''ELECTRA_PRETRAINE...
657
0
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor snake_case_ : str = logging.get_logger(__name__) class __snake_case ( a ): def __init__( self : List[Any] , *_snake_case : int ...
169
def A (__A : int ) -> bool: """simple docstring""" if not isinstance(__A , __A ): UpperCAmelCase_ = F"""Input value of [number={number}] must be an integer""" raise TypeError(__A ) if number < 0: return...
169
1
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor fr...
37
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokenization_comm...
37
1
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import...
704
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Union[str, Any] = { "configuration_git": ["GIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GitConfig", "GitVisionConfig"], "processing_git": ["GitProcessor"], } try:...
3
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer A : str = {"""vocab_file""": """vocab.txt""", """tokeniz...
516
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEncoder, ...
540
0
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __A ...
705
'''simple docstring''' import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( ...
10
0
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowercase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> List[Any]: ...
205
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_vision_available from ...test_configurati...
417
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 class _Upper...
454
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart impo...
454
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class a__ ( metaclass=a__ ): '''simple docstring''' lowercase__ : List[str] = ["transformers", "torch", "note_seq"] def __init__...
90
"""simple docstring""" from timeit import timeit def UpperCAmelCase ( snake_case : int ): if number < 0: raise ValueError('''the value of input must not be negative''' ) _lowerCAmelCase:str = 0 while number: number &= number - 1 ...
227
0
'''simple docstring''' import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCAmelCase_ ( a : Optional[int] , a : str=False ): a__ = OmegaConf.load(a ) if display: ...
719
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_comm...
126
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE = {'configuration_ibert': ['IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'IBertConfig', 'IBertOnnxConfig']} try: if not is_torch_available(): r...
220
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNA...
220
1
import unittest import numpy as np from datasets import load_dataset 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_...
702
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase = None, UpperCAmel...
336
0
from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE ( lowerCAmelCase ): '''simple docstring''' UpperCamelCase_ : int = ['''image_processor''', '''feature_extractor'''] UpperCamelCase_ : Union[str, Any] = '''TvltImageProce...
62
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch i...
514
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/ma...
572
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( snake_case_ = 100 ): _lowercase = set() _lowercase = 0 _lowercase = n + 1 # maximum limit for a in range(2 , snake_case_ ): for b in range(2 , snake_case_ ): _lowercase = a**b # calculat...
572
1
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_...
28
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedule...
28
1
"""simple docstring""" import inspect import unittest from transformers import ConvNextConfig 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 im...
706
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES UpperCAmelCase__ =logging.get_logger(__name__) UpperCAmelCase__ ...
442
0
"""simple docstring""" def snake_case_ ( A_ : str = 2_00 ): '''simple docstring''' _lowerCamelCase : Dict = [1, 2, 5, 10, 20, 50, 1_00, 2_00] _lowerCamelCase : Union[str, Any] = [0] * (pence + 1) _lowerCamelCase : ...
83
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 numpy as np import tensorflow as tf from transformers import TFCamembertModel...
295
0
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Flax...
315
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availabl...
315
1