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 requests lowerCamelCase_ = 'YOUR API KEY' def SCREAMING_SNAKE_CASE_ ( __A : str , __A : str = giphy_api_key ) -> list: _SCREAMING_SNAKE_CASE = "+".join(query.split() ) _SCREAMING_SNAKE_CASE = f"""https://api.giphy....
418
'''simple docstring''' import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchE...
418
1
'''simple docstring''' import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_te...
718
'''simple docstring''' 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 a : Tuple = False class UpperCamelCase_ ( unit...
672
0
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tenso...
62
"""simple docstring""" import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = {} __SCREAMING_S...
155
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowerCamelCase ={ "configuration_speech_to_text": ["SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_M...
716
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase ={ "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CLIPSegVisionConfig", ], ...
462
0
"""simple docstring""" import sys import turtle def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelC...
644
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar __lowerCAmelCase : Dict = TypeVar("KT") __lowerCAmelCase : Optional[Any] = TypeVar("VT") class a_ ( Generic[KT, VT] ): def __init__( s...
644
1
"""simple docstring""" import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # o...
85
"""simple docstring""" import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTI...
85
1
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @requ...
580
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': ( '''https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_i...
580
1
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRuntimeMod...
709
def _A (UpperCamelCase : List[Any] , UpperCamelCase : Dict ) ->List[str]: '''simple docstring''' lowerCamelCase__ : int = [1] for i in range(2 , UpperCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k...
96
0
"""simple docstring""" from __future__ import annotations __UpperCamelCase : List[str] = '''#''' class a : def __init__( self ): """simple docstring""" lowerCAmelCase = {} def UpperCamelCase__ ( self , _snake_case ...
4
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , a__ : list[tuple[float, float]] ): __magic_name__ = list_of_points ...
432
0
import warnings from .generation import TFGenerationMixin class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): # warning at import time warnings.warn( 'Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ' 'be...
708
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.tra...
388
0
from __future__ import annotations import math def lowerCAmelCase_ ( __UpperCAmelCase: Tuple ) -> bool: 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...
253
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils impo...
591
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except...
701
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __A = re.compile(R"^(?P<major>\d+)" R"\.(?P<minor>\d+)" R"\.(?P<patch>\d+)$") @total_ordering @dataclass class _SCREAMING_SNAKE_CASE...
437
0
from math import ceil, sqrt def lowerCAmelCase_ ( __a = 1000000 ) -> int: """simple docstring""" lowerCamelCase__: Any =0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowerCamelCase__: Optional[int] =...
59
'''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 UpperCamelCase__ ( lowercase_ ): ...
379
0
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia ...
330
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_util...
330
1
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_fl...
44
import argparse import os import re import packaging.version SCREAMING_SNAKE_CASE__ = "examples/" SCREAMING_SNAKE_CASE__ = { "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(R"^__version__\s+=\s+\...
631
0
'''simple docstring''' def lowercase ( lowerCAmelCase : int = 100_0000): """simple docstring""" _A : Any = 1 _A : str = 1 _A : Dict = {1: 1} for inputa in range(2 , lowerCAmelCase): _A : Any = 0 ...
417
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
417
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { "vinvino02/glpn-kitti": "https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json", # See all GLPN models at https://huggingface.co/mod...
109
"""simple docstring""" from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a__ ( snake_case__ ) -> Dict[str, torch.Tensor]: lowerCamelCase = [] lowerCamelCase = [...
543
0
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets __A = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into acco...
173
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class a ( ctypes.Structure ): # _fields is a specific attr expected by ctypes A_ : Dict = [(...
173
1
'''simple docstring''' from statistics import mean, stdev def _lowerCAmelCase ( lowerCamelCase_ : list , lowerCamelCase_ : int = 3 ): __lowercase = min(lowerCamelCase_ ) __lowercase = max(lowerCamelCase_ ) # normalize dat...
502
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMi...
502
1
'''simple docstring''' from math import log from scipy.constants import Boltzmann, physical_constants a__ = 300 # TEMPERATURE (unit = K) def snake_case__ ( a , a , a , ) -> float: '''simple docstring''' if donor_conc <= 0: raise ValueErr...
566
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose...
566
1
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase: List[str] = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def lowerCamelCase__ ( _A = "mumbai" ): a : List[str] ...
526
'''simple docstring''' import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore lowerCAmelCase: Optional[int] = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" lowerCAmelCase: O...
526
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(F...
73
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCAmelCase__ ( ...
73
1
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __lowercase ( _UpperCAmelCase): """simple docstring""" _A : Optional[int] = ["""image_processor""", """tokenizer"""] ...
480
"""simple docstring""" from math import factorial def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : int = 2_0 ): """simple docstring""" snake_case_ : int = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,......
480
1
"""simple docstring""" from collections import Counter from timeit import timeit def lowercase ( __snake_case : List[Any] = "" , ): return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase ...
710
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForOb...
141
0
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def SCREAMING_SNAKE_CASE__ ( snake_case__ :BertModel , snake_case__ :str , snake_case__ :str ) -> int: _lowercase = ('dense.weight', ...
67
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: if not ...
67
1
'''simple docstring''' import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup UpperCamelCase__: List[Any] = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" " (KHTML, like Geck...
528
'''simple docstring''' import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, ...
528
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __A : Tuple = {'configuration_vit': ['VIT_PRETRAINED_CONFIG_ARCH...
394
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_config...
394
1
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( _UpperCamelC...
346
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
346
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=snake_case ): UpperCamelCase =["torch", "transformers", "onnx"] def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> Union...
76
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceC...
453
0
"""simple docstring""" from __future__ import annotations from functools import lru_cache from math import ceil _SCREAMING_SNAKE_CASE : str = 100 _SCREAMING_SNAKE_CASE : Any = set(range(3, NUM_PRIMES, 2)) primes.add(2) _SCREAMING_SNAKE_CAS...
137
"""simple docstring""" import math def lowerCamelCase__ ( _lowerCamelCase : int ) -> bool: assert isinstance(_lowerCamelCase , _lowerCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2...
137
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_c...
182
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_...
182
1
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import pa...
274
"""simple docstring""" import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy ...
274
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import Model...
320
'''simple docstring''' from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from tra...
614
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyN...
114
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, ) lowercase : Union[str, Any] = {'''configuration_xglm''':...
114
1
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging snake_case_ = log...
507
from math import factorial def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or su...
335
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : List[str] = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETRA...
657
def __lowercase ( __lowerCAmelCase : int ): a__ = generate_pascal_triangle(__lowerCAmelCase ) for row_idx in range(__lowerCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ...
657
1
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def __magic_name__ ( ) -> str: '''simple docstring''' raise RuntimeError('''CUDA out of m...
535
"""simple docstring""" import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAm...
535
1
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_re...
231
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) _snake_case = {'''configuration_beit''': ['''BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BeitConfig''', '''BeitOnnx...
231
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
60
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase_ ( _UpperCamelCase ) -> Union[str, Any]: """simple docstring""" return getitem, k def lowerCamelCase_ ( _UpperCamelCase ,...
60
1
from itertools import permutations def UpperCamelCase (lowercase_: tuple ) -> bool: if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False A__ : Tuple = [7, 11, 13, 17] for i, test in enumerate(lowercase_ ...
64
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Config...
64
1
from __future__ import annotations def _lowerCamelCase ( lowerCamelCase_: list[int] , lowerCamelCase_: int , lowerCamelCase_: int , lowerCamelCase_: int ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) o...
256
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transp...
158
0
"""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 requir...
708
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_uti...
523
0
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand from ...
699
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "vocab_file": "vocab.json", "tokenizer_config_file": "to...
699
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __snake_case ( ): __a = ArgumentParser( description=( '''PyTorch TPU distributed training launch ''' ...
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
import operator as op def __a ( SCREAMING_SNAKE_CASE ) -> str: '''simple docstring''' __UpperCAmelCase = [] __UpperCAmelCase = lambda SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : int(x / y ) # noqa: E731 integer division opera...
303
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNo...
303
1
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, Path...
712
import inspect import unittest from transformers import MobileViTConfig 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_configuration_common import ConfigTester from ...t...
235
0
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _A ( __l...
26
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
0
from typing import Any def UpperCamelCase ( _A : Optional[Any] , _A : Optional[Any] , _A : Dict , _A : Optional[int] , _A : Union[str, Any] , )-> list: """simple docstring""" _validation( __snake_cas...
712
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): fr...
232
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''facebook/data2vec-text-bas...
39
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH fro...
39
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices A_ = logging.get_logger(__name__) A_ = { "shi-labs/nat-min...
465
'''simple docstring''' def A_ ( snake_case = 100 ): SCREAMING_SNAKE_CASE:Dict = 0 SCREAMING_SNAKE_CASE:Optional[int] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ =...
465
1
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(...
13
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : list[int] ,_UpperCAmelCase : int ) -> bool: _a : Optional[int] =len(_UpperCAmelCase ) _a : Tuple =[[False] * (required_sum + 1) for _ in r...
694
0
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import AN...
212
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
212
1
"""simple docstring""" class _UpperCAmelCase: def __init__( self , __a , __a , __a) -> Union[str, Any]: '''simple docstring''' _UpperCamelCase = None _UpperCamelCase = None _UpperCamelCa...
19
"""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_convbert import ConvBertTokenizer __lowerCAmelCase : ...
58
0
"""simple docstring""" def lowercase_ ( _lowercase : int , _lowercase : List[str] , _lowercase : Dict , _lowercase : int , _lowercase : Union[str, Any] ): '''simple docstring''' if index ...
710
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configura...
292
0
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseScheduler, DPMSol...
192
import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ran...
192
1
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_envir...
717
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : List[Any] = { "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): raise Option...
453
0
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a__ : def __init__( self : List[str] ): """simple docstring""" __lowerCamelCase = '''''' __lowerCamelCase ...
546
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging __Upp...
546
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase : Union[str, Any] ={"configuration_opt": ["OPT_PRETRAINE...
574
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
574
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowerCAmelCase__ ="\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
482
"""simple docstring""" import torch def _a ( ) -> List[Any]: if torch.cuda.is_available(): __SCREAMING_SNAKE_CASE = torch.cuda.device_count() else: __SCREAMING_SNAKE_CASE = 0 print(f"""Successfully ran on {num_gpus} GPUs""" )...
482
1
'''simple docstring''' from __future__ import annotations from collections import deque class _snake_case : """simple docstring""" def __init__( self : int , UpperCamelCase_ : list[str] ): lowerCAmelCase_ : list[dict] =[] self.adlist.append( ...
305
'''simple docstring''' from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def SCREAMING_SNAKE_CASE__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ...
305
1
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets a : List[Any] = "\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n and Saurav K...
679
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device fro...
130
0
# 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 BaseOutput, randn_tensor...
721
_SCREAMING_SNAKE_CASE = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-'...
83
0
from collections import Counter from timeit import timeit def SCREAMING_SNAKE_CASE__ ( snake_case_ = "", ) -> bool: """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(''' ''', '''''' ).lower() ).values() ) < 2 def SCREAMING_SNAKE_CASE__ ...
387
'''simple docstring''' from __future__ import annotations from typing import Any class a_ : def __init__( self , _SCREAMING_SNAKE_CASE = 6 ) -> None: """simple docstring""" UpperCamelCase = None UpperCamel...
301
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
718
import datasets from .evaluate import evaluate snake_case__ = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } ''' snake...
373
0
from __future__ import annotations from dataclasses import dataclass @dataclass class _lowerCamelCase : __a = 42 __a = None __a = None def A__ ( snake_case_ : TreeNode | None ): # Validation def is_valid_tree(snake_case_ : TreeNode | None ) -> ...
64
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
1
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
341
"""simple docstring""" import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import...
341
1
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( snake_case : str ): _lowerCAmelCase:str = args.pruning_method _lowerCAmelCase:Any ...
439
"""simple docstring""" def UpperCAmelCase ( snake_case : str , snake_case : str ): assert x is not None assert y is not None _lowerCAmelCase:Optional[Any] = len(snake_case ) _lowerCAmelCase:Tuple = len(snake_case ) # declar...
439
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase = { '''configuration_electra''': ['''ELECTRA_PRETRAINED_CONF...
91
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase ( UpperCamelCase__ : int ): """simple docstring""" # A local function to see if a dot lands in the circle. de...
262
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, ConditionalDetrForSegmentation, ...
206
def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__magic_name__ , n - 1 , __magic_name__ ) * a) % mod else: _lowercase: int = binary_exponentiation(__magic_n...
206
1
def _lowerCamelCase( __snake_case = 10**9 ) -> int: __snake_case = 1 __snake_case = 2 __snake_case = 0 __snake_case = 0 __snake_case = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter prev_value += 2 * value value += prev...
524
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-tes...
524
1
from math import isqrt def SCREAMING_SNAKE_CASE_ ( __A : int ) -> bool: """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(__A ) + 1 ) ) def SCREAMING_SNAKE_CASE_ ( __A : ...
443
def SCREAMING_SNAKE_CASE_ ( __A : str ) -> list: """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__A ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('d...
443
1
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import Gradi...
117
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __magic_name__ (snake_case_ ): '''simple docstring''' __lowercase : List[str] = ['image_processor', 'tokenizer'] __lowercase :...
33
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 __lowercase = ...
713
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase :str = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependen...
26
0
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar lowercase_ = TypeVar("T") class UpperCAmelCase_ (Generic[T] ): """simple docstring""" def __init__( self : Dict , a_ : T )-> None: """simple docstr...
470
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_g...
470
1
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def lowerCamelCase( a__ = "isbn/0140328726"): '''simple docstring''' _SCREAMING_SNAKE_CASE =olid.strip().strip('''/''') # Remove leading/trailing whitespace & slashes if new_o...
707
from datetime import datetime import matplotlib.pyplot as plt import torch def lowerCamelCase( a__): for param in module.parameters(): _SCREAMING_SNAKE_CASE =False def lowerCamelCase( ): _SCREAMING_SNAKE_CASE ='''cuda''' if torch.cuda.is_available() else '''cpu'...
191
0
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, require_tf, require_torch fr...
339
'''simple docstring''' def _snake_case ( A_ : str , A_ : str ): """simple docstring""" if not (isinstance(A_ , A_ ) and isinstance(A_ , A_ )): raise ValueError("""longest_common_substring() takes two strings for inputs""" ) a_ : Optional[int...
577
0
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision impor...
211
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( Au...
211
1
'''simple docstring''' import os import sys UpperCamelCase__ = os.path.join(os.path.dirname(__file__), '''src''') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, ...
75
from __future__ import annotations def a__ ( A_, A_ ): '''simple docstring''' if b == 0: return (1, 0) ((__magic_name__) , (__magic_name__)) = extended_euclid(A_, a % b ) __magic_name__ = a // b return (y, x - k * y) def a__ ( ...
529
0
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem a : Any = importlib.util.find_spec('''s3fs''') is not None if _ha...
719
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
0
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort...
37
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ 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 ( Au...
64
0
_UpperCAmelCase = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", """M""": """--""", """N""": """-.""", ...
70
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class UpperCAmelCase ( tf.keras.optimizers.schedules.LearningRateSchedule ): ...
70
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A : Any = {'configuration_vit_mae': ['VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMAEConfig']} try: if n...
315
from random import randint from tempfile import TemporaryFile import numpy as np def _a ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> List[str]: """simple docstring""" lowerCamelCase__ : Tuple = 0 if start < end: lowerCamelCase__ : ...
315
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: if not is_tokenizers_available(): ...
234
A = 8.3_14_45_98 def lowerCamelCase ( UpperCamelCase : float , UpperCamelCase : float ) -> float: if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) if molar_mass <= 0: raise Exception('Molar mass cannot be less than or...
234
1
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformer...
556
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" if not arr: return None, N...
496
0
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __lowercase ( ...
703
"""simple docstring""" import unittest from transformers import BertGenerationConfig, 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_mo...
497
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__ : Dict = { """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConfig""", """CLIPSegTextCon...
13
"""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 transformers.t...
265
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, l...
709
from math import pow def UpperCAmelCase__ ( _A , _A , _A , _A , _A , ): """simple docstring""" if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 r...
143
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { """xlm-mlm-en-2048""": """https://huggingf...
29
"""simple docstring""" import os from datetime import datetime as dt from github import Github A_ = [ """good first issue""", """feature request""", """wip""", ] def lowercase ( ): lowerCamelCase_ = Github(os.environ['''GITHUB_TOKEN'''] ) lowerCamelCase_ =...
29
1
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): i...
644
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __a (unittest.Te...
644
1
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 ( IMAGENET_STANDARD_MEAN, ...
461
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_forma...
461
1
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class snake_case_ (lowerCamelCase_ , unittest.TestCase ): UpperCAmelCase__ : str = DownBlockaD # n...
714
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
0
def _a ( lowercase__ : Tuple , lowercase__ : Union[str, Any] ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Tuple = [1] for i in range(2 , lowercase__ ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k ou...
85
"""simple docstring""" def snake_case__ ( _lowerCamelCase ) ->str: """simple docstring""" if isinstance(_lowerCamelCase, _lowerCamelCase ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(_lowerCamelCase, _lowerCamelCase...
575
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __snake_case : Optional[int] = logging.get_logger(__name__) __snake_case : str = R""" Args: in...
365
from __future__ import annotations __snake_case : Any = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C""...
365
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record lowercase_: int = '\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n author=...
648
def lowerCamelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : int ) -> list: """simple docstring""" __lowerCamelCase = word.split() def justify(UpperCamelCase__ : list , UpperCamelCase__ : int , UpperCamelCase__...
469
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = '▁' Uppe...
716
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() ...
369
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Co...
240
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowercase = HfArgumentParser(InitializationArguments) lowercase = parser.parse_args() # Load codeparrot tokenizer trained for Python...
240
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __magic_name__ = { 'configuration_conditional_detr': [ 'CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConditionalDetrConfig', ...
709
import re def __snake_case ( _UpperCAmelCase ): """simple docstring""" if len(re.findall('[ATCG]' , _UpperCAmelCase ) ) != len(_UpperCAmelCase ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans(...
314
0
import qiskit def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): a__ = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register a__ = qiskit.QuantumCircuit(__lowerCAmelCase , __lowerCA...
335
import argparse import datetime def __lowercase ( __lowerCAmelCase : str ): a__ = { '0': 'Sunday', '1': 'Monday', '2': 'Tuesday', '3': 'Wednesday', '4': 'Thursday', '5': 'Friday', '6': 'Saturday', }...
335
1
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 UpperCAmelCase__ = logging.getLogger(__name__) UpperCAmelCase__ = 50 # max width of layer nam...
639
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM, ...
639
1