code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import numpy # List of input, output pairs __snake_case :Optional[int] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) __snake_case :Dict = (((515, 22, 13), 555), ((61, 35, 49), 150)) __snake_case :List[Any] = [2, 4, 1, 5] __snake_c...
60
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_inputs if is...
60
1
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline __snake_case :List[str] = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False) parser.add_argument('''--dpm''', action...
60
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : int): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
60
1
from manim import * class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : List[Any]): '''simple docstring''' __a = Rectangle(height=0.5 , width=0.5) __a = Rectangle(height=0.25 , width=0.25) __a = Rectang...
60
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
60
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 __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
1
import requests def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = {'''Content-Type''': '''application/json'''} __a = requests.post(_UpperCAmelCase , json={'''text''': message_body} , headers=_UpperCAmelCase ) if response.status_cod...
60
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case :List[str] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''InstructBlipQFormer...
60
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
1
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): return round(float(moles / volume ) * nfactor ) def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): return round(float((moles * 0.08_21 * tem...
60
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(_UpperCAmelCase ): print(f'{i}\t\t{d}' ) def __snake_case ( _UpperCAmelCase ...
60
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class _A ( __UpperCAmelCase ): UpperCamelCase__ : int = (DDIMParallelScheduler,) UpperCamelCase__ : Optional[Any] = (('''eta''', 0.0), ('''num_infer...
60
import os import sys import unittest __snake_case :Union[str, Any] = 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, fi...
60
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_numpy, slow, to...
60
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
60
1
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
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 ) __snake_case :Tuple = logging.getLogger(__name__) if __name__ == "__main__": __snake...
60
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case :Optional[int] = { '''configuration_upernet''': ['''UperNetConfig'''], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependen...
60
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils impo...
60
from collections.abc import Generator from math import sin def __snake_case ( _UpperCAmelCase ): if len(_UpperCAmelCase ) != 32: raise ValueError('''Input must be of length 32''' ) __a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * ...
60
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Dict = logging.get_logger(__name__) __snake_case :Optional[Any] = { '''tiiuae/falcon-40b''': '''https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json''', '''tiiuae/falcon-7b''': '''https:/...
60
# 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 __snake_case :Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io #...
60
1
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def __snake_case ( _UpperCAmelCase ): if not is_accelerate_available(): return method __a = version.parse(accelerate.__version__ ).base_...
60
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): __a = f'Expected string as input, found {type(_UpperCAmelCase )}' raise ValueError(_UpperCAmelCase ) if not isinstance(...
60
1
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __snake_case ( _UpperCAmelCase ): if "model" in orig_key: __a = orig_key.replace('''model.''' , '''''' ) if "norm1" in orig_key: __a = orig_key.replace('''no...
60
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __snake_case :List[str] = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass class _A : ...
60
1
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata __snake_case :int = '''''' ...
60
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) __snake_case :str = { '''configuration_speecht5''': [ '''SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SPEECHT5_PRETRAINE...
60
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __snake_case :Union[str, Any] = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''V...
60
1
import argparse 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 accelerate import Accelerator, D...
60
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 __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case :str = { '''configuration_mobilebert''': [ '''MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
60
from __future__ import annotations __snake_case :Optional[Any] = [] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): for i in range(len(_UpperCAmelCase ) ): if board[row][i] == 1: return False for i in range(len(_...
60
1
from __future__ import annotations import numpy as np def __snake_case ( _UpperCAmelCase ): __a , __a = np.shape(SCREAMING_SNAKE_CASE_ ) if rows != columns: __a = ( '''\'table\' has to be of square shaped array but got a ''' f'{row...
700
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
0
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): while b: __a , __a = b, a % b return a def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): return a if b == 0 else euclidean_gcd_recursive(__A , a % b ) def __...
701
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez import B...
60
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Union[str, Any] = logging.get_logger(__name__) __snake_case :List[str] = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class _A ( snake_case__ ): UpperCamelCase__ : ...
702
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __snake_case :Optional[int] = collections.namedtuple('''_Datasets''', ['''trai...
60
0
import qiskit def __snake_case ( _UpperCAmelCase = 2 ): '''simple docstring''' __a = qubits # Using Aer's simulator __a = qiskit.Aer.get_backend('''aer_simulator''' ) # Creating a Quantum Circuit acting on the q register __a = qiskit.Qu...
703
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_inputs if is...
60
0
from __future__ import annotations class _A : def __init__( self : Dict , __SCREAMING_SNAKE_CASE : str , __SCREAMING_SNAKE_CASE : str): '''simple docstring''' __a = text, pattern __a = len(UpperCamelCase_), len(UpperCamelCase...
704
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : int): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
60
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 : UpperCamelCase__ : int = 42 UpperCamelCase__ : List[Any] = None ...
705
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
60
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_a...
706
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case :List[str] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_available(): raise OptionalDepende...
707
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
0
from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_mask ...
708
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
0
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_re...
709
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(_UpperCAmelCase ): print(f'{i}\t\t{d}' ) def __snake_case ( _UpperCAmelCase ...
60
0
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
710
import os import sys import unittest __snake_case :Union[str, Any] = 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, fi...
60
0
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = " " ): __a = [] __a = 0 for index, char in enumerate(_lowerCAmelCase ): if char == separator: split_words.append(string[last_index:index] ) __a = index + 1 ...
711
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
60
0
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase...
712
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 ) __snake_case :Tuple = logging.getLogger(__name__) if __name__ == "__main__": __snake...
60
0
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand __snake_case :Optional[Any] = logging.get_logger(__name__) # pylint: disable=invalid-name def __snake_case ( _...
713
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
0
'''simple docstring''' import math from collections.abc import Iterator from itertools import takewhile def __snake_case ( _UpperCAmelCase ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives...
714
from collections.abc import Generator from math import sin def __snake_case ( _UpperCAmelCase ): if len(_UpperCAmelCase ) != 32: raise ValueError('''Input must be of length 32''' ) __a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * ...
60
0
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Acce...
715
# 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 __snake_case :Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io #...
60
0
import random def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = False ) -> Tuple: __a = {i: [] for i in range(_lowerCamelCase )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
716
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): __a = f'Expected string as input, found {type(_UpperCAmelCase )}' raise ValueError(_UpperCAmelCase ) if not isinstance(...
60
0
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = sorted(numsa + numsa ) __a = divmod(len(_lowerCamelCase ) , 2 ) if mod == 1: return all_numbers[div] else: return (all_nu...
717
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __snake_case :List[str] = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass class _A : ...
60
0
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin __snake...
718
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata __snake_case :int = '''''' ...
60
0
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _A ( _UpperCAmelCase ): UpperCamelCase__ : Li...
719
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __snake_case :Union[str, Any] = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''V...
60
0
'''simple docstring''' def __snake_case ( _UpperCAmelCase ): __a = len(_UpperCAmelCase ) __a = sum(_UpperCAmelCase ) __a = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n + 1 ): __a ...
720
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 __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
0
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va,...
721
from __future__ import annotations __snake_case :Optional[Any] = [] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): for i in range(len(_UpperCAmelCase ) ): if board[row][i] == 1: return False for i in range(len(_...
60
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def __snake_case ( _UpperCAmelCase ): __a = 384 ...
700
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
0
__snake_case :Union[str, Any] = tuple[float, float, float] __snake_case :List[str] = tuple[float, float, float] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = end_pointa[0] - end_pointa[0] __a = end_pointa[1] - end_pointa[1] __a = ...
701
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez import B...
60
0
import os __snake_case :Tuple = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def __snake_case ( _UpperCAmelCase ) -> Union[str, Any]: __a = 0 __a = 0 while index < len(_UpperCAmelCase ) - 1: __a...
702
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __snake_case :Optional[int] = collections.namedtuple('''_Datasets''', ['''trai...
60
0
from ..utils import DummyObject, requires_backends class _A ( metaclass=UpperCamelCase_ ): UpperCamelCase__ : int = ['''torch''', '''torchsde'''] def __init__( self : List[str] , *__SCREAMING_SNAKE_CASE : List[str] , **__SCREAMING_SNAKE_CASE : str...
703
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_inputs if is...
60
0
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ...
704
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : int): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
60
0
import itertools import string from collections.abc import Generator, Iterable def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = iter(_UpperCAmelCase ) while True: __a = tuple(itertools.islice(_UpperCAmelCase , _UpperCA...
705
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
60
0
'''simple docstring''' import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput ...
706
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
707
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
0
from collections.abc import Sequence from queue import Queue class _A : def __init__( self : Union[str, Any] , __SCREAMING_SNAKE_CASE : Any , __SCREAMING_SNAKE_CASE : List[Any] , __SCREAMING_SNAKE_CASE : Tuple , __SCREAMING_SNAKE_CASE : Dict=None , __SCREAMING...
708
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
0
import unittest import numpy as np import requests 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 is_torch_available():...
709
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(_UpperCAmelCase ): print(f'{i}\t\t{d}' ) def __snake_case ( _UpperCAmelCase ...
60
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig''', '''CLIPSegVision...
710
import os import sys import unittest __snake_case :Union[str, Any] = 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, fi...
60
0
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): if len(_snake_case ) < k or k < 0: raise ValueError('''Invalid Input''' ) __a = __a = sum(array[:k] ) for i in range(len(_snake_case ) - k ...
711
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
60
0
import numpy as np def __snake_case ( _UpperCAmelCase ): return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
712
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 ) __snake_case :Tuple = logging.getLogger(__name__) if __name__ == "__main__": __snake...
60
0
def __snake_case ( _UpperCAmelCase ): if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(__UpperCamelCase , __UpperCamelCase ): raise TypeError('''Input value must be a \'int\' type''' ) return bin(__UpperCamelCase ...
713
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
0
'''simple docstring''' import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class _A ( UpperCAmelCase__ ,UpperCAmelCase__ ): UpperCamelCase__ ...
714
from collections.abc import Generator from math import sin def __snake_case ( _UpperCAmelCase ): if len(_UpperCAmelCase ) != 32: raise ValueError('''Input must be of length 32''' ) __a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * ...
60
0
'''simple docstring''' import unittest import numpy as np import requests 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_inpu...
715
# 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 __snake_case :Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io #...
60
0
from __future__ import annotations class _A : def __init__( self : Dict , __SCREAMING_SNAKE_CASE : int): '''simple docstring''' __a = order # a_{0} ... a_{k} __a = [1.0] + [0.0] * order # b_{0} ... b_{k} ...
716
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): __a = f'Expected string as input, found {type(_UpperCAmelCase )}' raise ValueError(_UpperCAmelCase ) if not isinstance(...
60
0
def __snake_case ( _UpperCAmelCase = "The quick brown fox jumps over the lazy dog" , ): __a = set() # Replace all the whitespace in our sentence __a = input_str.replace(''' ''' , '''''' ) for alpha in input_str: if "a" <= alpha.lower() <= "z": ...
717
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __snake_case :List[str] = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass class _A : ...
60
0
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __snake_case :Optional[int] = TypeVar('''KEY''') __snake_case :str = TypeVar('''VAL''') @dataclass(frozen=UpperCAmelCase__ ,slots=UpperCAmelCase__ ) class _A ( Generic[...
718
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata __snake_case :int = '''''' ...
60
0
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
719
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __snake_case :Union[str, Any] = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''V...
60
0
'''simple docstring''' from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = get_failure_array(UpperCamelCase__ ) # 2) Step through text searching for pattern __a = 0, 0 # index into text, pattern while ...
720
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 __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Tuple = logging.get_logger(__name__) class _A ( __UpperCAmelCase ): UpperCamelCase__ : Optional[int] = '''timm_backbone''' def __init__( self : Any , __SCREAMIN...
721
from __future__ import annotations __snake_case :Optional[Any] = [] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): for i in range(len(_UpperCAmelCase ) ): if board[row][i] == 1: return False for i in range(len(_...
60
0
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTe...
700
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file, and ...
701
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez import B...
60
0
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 __snake_case :Optional[Any] = logging.get_logger(__name__) _...
702
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __snake_case :Optional[int] = collections.namedtuple('''_Datasets''', ['''trai...
60
0
import math from datetime import datetime, timedelta def __snake_case ( _UpperCAmelCase ): '''simple docstring''' __a = year % 19 __a = year % 4 __a = year % 7 __a = math.floor(year / 100 ) __a = math.floor((13 + 8 * leap_...
703
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_inputs if is...
60
0
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __snake_case :Any = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __snake_case :Tuple = [file for file in filepaths if file...
704
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : int): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
60
0
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case :List[str] = logging.get_logger(__name__...
705
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
60
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class _A ( metaclass=__UpperCAmelCase ): UpperCamelCase__ : int = ["torch", "transformers", "onnx"] def __init__( self : int , *__SCREAMING_SNAKE_CASE : Any , **__SCREAMING_SN...
706
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
0
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC __snake_case :str = parse(importlib.metadata.version('''torch''')) def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ...
707
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case :List[str] = { '''configuration_xlm_roberta''': [ ...
708
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
0
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ( ...
709
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(_UpperCAmelCase ): print(f'{i}\t\t{d}' ) def __snake_case ( _UpperCAmelCase ...
60
0
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from...
710
import os import sys import unittest __snake_case :Union[str, Any] = 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, fi...
60
0
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch __snake_case :List[Any] ...
711
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
60
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __snake_case :Dict = logging.get_logger(__name__) __snake_case :List...
712
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 ) __snake_case :Tuple = logging.getLogger(__name__) if __name__ == "__main__": __snake...
60
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __snake_case :Tuple = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: __snake_case :List[Any]...
713
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
0
'''simple docstring''' class _A : def __init__( self : int): '''simple docstring''' __a = '''''' __a = '''''' __a = [] def _lowerCamelCase ( self : Optional[Any] , __SCREAMING_SNAKE_CASE : ...
714
from collections.abc import Generator from math import sin def __snake_case ( _UpperCAmelCase ): if len(_UpperCAmelCase ) != 32: raise ValueError('''Input must be of length 32''' ) __a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * ...
60
0
'''simple docstring''' from __future__ import annotations import requests __snake_case :List[Any] = set( '''approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked c...
715
# 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 __snake_case :Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io #...
60
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case :Tuple = {'''configuration_xlnet''': ['''XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP''...
716
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): __a = f'Expected string as input, found {type(_UpperCAmelCase )}' raise ValueError(_UpperCAmelCase ) if not isinstance(...
60
0
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Dict = logging.get_logger(__name__) __snake_case :Dict = { '''microsoft/xprophetnet-large-wiki100-cased''': ( '''https://huggingface.co/microsoft/xpro...
717
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __snake_case :List[str] = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass class _A : ...
60
0
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common i...
718
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata __snake_case :int = '''''' ...
60
0
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _A ( __UpperCAmelCase ): UpperCamelCase__ : str = (IPNDMScheduler,) UpperCamelCase__ : Union[str, Any] = (('''num_inference_steps'''...
719
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __snake_case :Union[str, Any] = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''V...
60
0
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPP...
720
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 __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
0
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor __snake_case :Union[str, Any] = logging.getLogger(__name__) __snake_case :str = 50 # max wi...
721
from __future__ import annotations __snake_case :Optional[Any] = [] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): for i in range(len(_UpperCAmelCase ) ): if board[row][i] == 1: return False for i in range(len(_...
60
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # Init...
700
def __snake_case ( _UpperCAmelCase ): __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 __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for i in r...
60
0
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configur...
701
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_barthez import B...
60
0
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ) -> str: if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __a = str(bin(SCREAMING_SNAKE_CASE_ ) )[2:] # remove the leading "0b" __a = str(bin(S...
702
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __snake_case :Optional[int] = collections.namedtuple('''_Datasets''', ['''trai...
60
0
from collections import defaultdict from math import ceil, sqrt def __snake_case ( _UpperCAmelCase = 1000000 , _UpperCAmelCase = 10 ): '''simple docstring''' __a = defaultdict(__lowercase ) for outer_width in range(3 , (t_limit // 4) + 2 ): ...
703
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_inputs if is...
60
0
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_r...
704
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __UpperCAmelCase ): def _lowerCamelCase ( self : int): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
60
0
import sys __snake_case :Optional[int] = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''66896...
705
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( _UpperCAmelCase ): __a = [] embed.append( ...
60
0
'''simple docstring''' from math import sqrt def __snake_case ( _UpperCAmelCase ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not prime...
706
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
0
class _A : def __init__( self : Optional[Any] , __SCREAMING_SNAKE_CASE : int): '''simple docstring''' __a = arr.split(''',''') def _lowerCamelCase ( self : str): '''simple docstring''' __a = [int(s...
707
from __future__ import annotations from random import random from typing import Generic, TypeVar __snake_case :Any = TypeVar('''KT''') __snake_case :List[str] = TypeVar('''VT''') class _A ( Generic[KT, VT] ): def __init__( self : Dict , __SCREAMING_SNAKE_CASE : KT | ...
60
0
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
708
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
0
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __snake_case :str = { 'gwf-440k': { 'u...
709
from __future__ import annotations def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(_UpperCAmelCase ): print(f'{i}\t\t{d}' ) def __snake_case ( _UpperCAmelCase ...
60
0
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _A ( unittest.TestCase ): def _lowerCamelCase ( self : Optional[int]): '''simple docstring''' debug_launcher(test_s...
710
import os import sys import unittest __snake_case :Union[str, Any] = 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, fi...
60
0
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, req...
711
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
60
0
def __snake_case ( _UpperCAmelCase ): if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) __a = sum(lowerCamelCase_ ) / len(lowerCamelCase_ ) # Calculate the average return sum(abs(x - average ) for x in n...
712
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 ) __snake_case :Tuple = logging.getLogger(__name__) if __name__ == "__main__": __snake...
60
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import I...
713
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __snake_case :List[str] = HfApi() __snake_case :str = {} # fmt: off __snake_case :Optional[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0_0, 0.6_3_4_7, 1.3_4_3_3, -1.1_7_4_3, -3.7...
60
0
'''simple docstring''' 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 f...
714
from collections.abc import Generator from math import sin def __snake_case ( _UpperCAmelCase ): if len(_UpperCAmelCase ) != 32: raise ValueError('''Input must be of length 32''' ) __a = b'''''' for i in [3, 2, 1, 0]: little_endian += string_aa[8 * ...
60
0