code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename UpperCAmelCase_ : Union[str, Any] = 'h...
32
from __future__ import annotations UpperCAmelCase_ : Tuple = [] def SCREAMING_SNAKE_CASE_ ( __A : list[list[int]] , __A : int , __A : int ) -> bool: """simple docstring""" for i in range(len(__A ) ): if boa...
32
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A__ : List[str] = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP'...
353
'''simple docstring''' def a_ ( _UpperCAmelCase : float ,_UpperCAmelCase : float ) -> float: return price * (1 + tax_rate) if __name__ == "__main__": print(F"""{price_plus_tax(1_0_0, 0.25) = }""") print(F"""{price_plus_tax(1_25.50, 0.05) = }""")
0
0
"""simple docstring""" import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, ...
150
"""simple docstring""" import itertools import string from collections.abc import Generator, Iterable def lowerCAmelCase__ ( _UpperCamelCase : Iterable[str] , _UpperCamelCase : int ) -> Generator[tuple[str, ...], None, None]: """simple docstring""" ...
150
1
"""simple docstring""" import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase :...
86
"""simple docstring""" from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 _lowercase : str = { # 1536-bit 5: { ...
86
1
lowerCamelCase : Tuple = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} lowerCamelCase : int = ['''a''', '''b''', '''c''', '''d''', '''e'''] def snake_case_ ( lowerCAmelCase_ : Optional[int] , low...
233
from itertools import permutations def snake_case_ ( lowerCAmelCase_ : tuple ): 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 __lowercase : ...
233
1
"""simple docstring""" 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, ) fro...
358
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
12
0
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 Confi...
9
from __future__ import annotations def _UpperCamelCase ( lowercase__ ): __SCREAMING_SNAKE_CASE : Dict = 0.00 __SCREAMING_SNAKE_CASE : List[str] = 0 for resistor in resistors: if resistor <= 0: __SCREAMING_SNAKE_CASE ...
9
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->str: '''simple docstring''' return "".join(chr(ord(_lowercase ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import test...
367
"""simple docstring""" a : Optional[int] = 8.31_4462 # Unit - J mol-1 K-1 def _SCREAMING_SNAKE_CASE ( _lowercase : float , _lowercase : float , _lowercase : float ) ->float: '''simple docstring''' if ...
79
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Any = logging.get_logger(__name__) snake_case : Dict = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/con...
281
import math def lowerCAmelCase_ ( _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' return math.pow(_snake_case , 2 ) - a def lowerCAmelCase_ ( _snake_case : float ) -> float: '''simple docstri...
281
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( Aut...
230
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE = { "configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "M...
230
1
"""simple docstring""" from __future__ import annotations from collections import deque class UpperCamelCase : def __init__( self, lowerCAmelCase__) -> Union[str, Any]: snake_case_ = [] self.adlist.append( {'value': '', 'ne...
69
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_...
140
0
"""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...
248
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=a_ ) class UpperCamelCase_ ( a_ ): _A : str = field(default='ima...
248
1
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_com...
251
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, ...
251
1
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def _UpperCamelCase ( snake_case__, snake_case__ ) -> Union[str, Any]: __UpperCAmelCase : List[Any] ...
350
import math _snake_case = 10 _snake_case = 7 _snake_case = BALLS_PER_COLOUR * NUM_COLOURS def _UpperCamelCase ( snake_case__ = 20 ) -> str: __UpperCAmelCase : Optional[Any] = math.comb(snake_case__, snake_case__ ) ...
342
0
"""simple docstring""" from manim import * class A_ ( A__ ): """simple docstring""" def UpperCAmelCase__ ( self :Union[str, Any] ): """simple docstring""" lowerCamelCase__ : Tuple =Rectangle(heig...
126
"""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-...
126
1
"""simple docstring""" from functools import lru_cache def UpperCAmelCase ( UpperCamelCase__ ): """simple docstring""" A__ = 2 A__ = set() while i * i <= n: if n % i: i ...
154
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( ...
154
1
"""simple docstring""" import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase fro...
242
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Optional[int] , SCREAMING_SNAKE_CASE_: int ...
68
0
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, Mu...
289
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] ) -> None: """simple docstring""" lowerCAmelCase_ : List[Any] = len(lowerCAmelCase__ ) print('The followin...
289
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ = {"""configuration_fnet""": ["""FNET_PRETRAINED_C...
191
"""simple docstring""" from scipy.stats import pearsonr import datasets lowerCamelCase_ : Optional[int] = """ Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The ...
81
0
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() A__ : Dict = logging.get_logger('''transformers.models.speecht5''') def a_ ( _UpperCAmelCase : Opti...
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer A__ : Union[str, Any] = {'''vocab_file''': '''vocab.txt''', '''tokeni...
0
1
import math from numpy import inf from scipy.integrate import quad def UpperCamelCase ( __lowerCamelCase : float ): if num <= 0: raise ValueError("math domain error" ) return quad(__lowerCamelCase , 0 , __lowerCamelCase , args=(__lower...
59
'''simple docstring''' import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers....
298
0
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavin...
86
"""simple docstring""" from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ...
86
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ :Optional[Any] = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], "...
101
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor ...
23
0
"""simple docstring""" 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, ...
230
"""simple docstring""" import random from .binary_exp_mod import bin_exp_mod def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_=10_00 ) -> Optional[Any]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd A__ = n - 1 A__ = 0 while...
230
1
"""simple docstring""" import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def __UpperCAmelCase ( UpperCAmelCase_ : List[str] , UpperCAmelCas...
172
"""simple docstring""" import flax.linen as nn import jax import jax.numpy as jnp class UpperCamelCase ( nn.Module ): UpperCAmelCase : int UpperCAmelCase : jnp.dtype = jnp.floataa def _lowercase (self : Any) -> Optional[int]: ...
172
1
'''simple docstring''' import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _SCREAMING_SNAKE_CASE : ...
92
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def UpperCamelCase_( snake_case : str , snake_case : complex , snake_case : str = "x" , snake_case : float = 1_0**-1_0 , snake_cas...
92
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : List[str] = logging.get_logger(__name__) lowercase : Union[str, Any] = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.j...
20
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig UpperCamelCase_ = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pytorch''': '''htt...
345
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a : Tuple = logging.get_logger(__name__) class __UpperCamelCase ( a__ ): def __init__( self ,...
350
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int ) ->bool: '''simple docstring''' return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
79
0
def _a ( lowerCamelCase: list ) -> float: '''simple docstring''' __A = 0 while len(lowerCamelCase ) > 1: __A = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): ...
117
# 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...
117
1
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __lowerCAmelCase ( unittest.TestCase ): @require_torch def ...
279
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder lowerCAmelCase_ = '''__DUMMY_TRANSFORMERS_USER__''' lowerCAmelCase_ = '''Dummy User''' lowerCAmelCase_ = '''hf_hZEmnoOEYISjraJtbySaKCNnSu...
279
1
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets A : Optional[Any] = datasets.logging.get_logger(__name__) A : str = "\\n@inproceedings{bleurt,\n title={BLEURT: Learning Robust Metrics for Text Generation},\n ...
184
def lowercase_ ( _A : int , _A : int ): """simple docstring""" while a != 0: lowerCamelCase__ , lowerCamelCase__ : Optional[Any] = b % a, a return b def lowercase_ ( _A : int , _A : int ): ...
184
1
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 transform...
363
import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from transform...
288
0
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_co...
37
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# _lowerCAmelCase = [ # (stable-diffusion, HF Diffusers) ('''time_embed.0.weight''', '''time_...
37
1
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : List[Any] =logging.get_logger(__name__) UpperCAmelCase__ : Dict ={ '''facebook/encodec_24khz''': '''https://huggingface.co/fac...
262
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,...
262
1
"""simple docstring""" 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(): from PIL import Image fro...
69
def lowerCAmelCase__ ( lowerCamelCase_ : list[list[float]]): '''simple docstring''' lowerCAmelCase__ : list[list[float]] = [] for data in source_data: for i, el in enumerate(lowerCamelCase_): if len(lowerCamelCase_) < i + 1: data_lis...
129
0
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A : Optional[Any] = logging.get_logger(__name__) __A : Any = { '''vocab_file''': '''vocab.json''', '''tokenizer...
323
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, lo...
323
1
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, Sta...
115
"""simple docstring""" __UpperCamelCase = frozenset( [ '''prompt''', '''height''', '''width''', '''guidance_scale''', '''negative_prompt''', '''prompt_embeds''', '''negative_prompt_embeds''', '''cross_attention_kwargs'...
113
0
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_effect...
247
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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_v...
247
1
'''simple docstring''' import unittest from transformers import DebertaConfig, 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_com...
168
'''simple docstring''' import numpy as np class a : def __init__( self ) -> List[str]: _a = (0, 0) _a = None _a = 0 _a = 0 _a = 0 def __eq__( self , __magic_name__...
168
1
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available,...
361
'''simple docstring''' def _lowerCamelCase ( lowerCamelCase_ : str , lowerCamelCase_ : str = " " ): """simple docstring""" UpperCAmelCase_ : str = [] UpperCAmelCase_ : List[Any] = 0 for index, char in enumerate(lowe...
274
0
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logg...
44
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def UpperCamelCase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str = "cpu" , lowerCAmelCase__ : Union[str, None] = None ) -> None: ...
224
0
from bisect import bisect from itertools import accumulate def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : List[str] , __UpperCamelCase : int , __UpperCamelCase : List[Any] , __UpperCamelCase : Optional[int] ) -> Dict: """simple docstring""" ...
204
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __lowerCamelCase : int = 4 __lowerCamelCase : Dict = 3 ...
204
1
"""simple docstring""" from __future__ import annotations class UpperCamelCase : def __init__( self, lowerCAmelCase__=None) -> Optional[int]: snake_case_ = data snake_case_ = None def __repr__( self) -> ...
69
import unittest from knapsack import greedy_knapsack as kp class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def lowerCAmelCase__ ( self : Any ) -> str: """simple docstring""" snake_case_ ...
159
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
282
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_...
282
1
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils imp...
336
'''simple docstring''' import os import pytest from attr import dataclass _snake_case = 'us-east-1' # defaults region @dataclass class a__ : _SCREAMING_SNAKE_CASE : str _SCREAMING_SNAKE_CASE : str = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' _SCREAMING...
250
0
def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(snake_case_ ) ) def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_ )...
343
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase (...
343
1
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder UpperCAmelCase_ : Optional[Any] = datasets.utils.logging.get_logger(__name__) class lowerCAmelCase__ ( folder_base...
91
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A: List[str] = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CL...
109
0
from ..utils import DummyObject, requires_backends class _A ( metaclass=snake_case__ ): _UpperCamelCase : Optional[Any] = ['''keras_nlp'''] def __init__( self : Dict , *_A : str , **_A : List[str] ) -> str: ...
365
class _A : # Public class to implement a graph def __init__( self : List[Any] , _A : int , _A : int , _A : list[list[bool]] ) -> None: """simple docstring""" lowercase : Tuple = row...
116
0
"""simple docstring""" import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets fr...
148
def A__ ( __lowerCamelCase = 10_00 ): SCREAMING_SNAKE_CASE_ = 2**power SCREAMING_SNAKE_CASE_ = 0 while n: SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input()).strip())))
299
0
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase , __lowerCAmelCase = len(_UpperCamelCase ), len(grid[0] ) if ( min(_UpperCamelCase , _Upp...
259
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mode...
259
1
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging _lowerCamelCase ={ """cola""": 2, ...
287
import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig from transformers.configuration_...
287
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common i...
357
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=_lowerCamelCase) class A__ ( _lowerCamelCase): # `task` is not a ClassVar since we want ...
182
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _snake_case( SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray ) -> float: '''simple docstring''' return math.sqrt(sum...
7
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices ...
7
1
import requests _snake_case : Any = '''YOUR API KEY''' def a_ ( lowerCAmelCase_ : str, lowerCAmelCase_ : str = giphy_api_key ): __lowerCAmelCase = """+""".join(query.split() ) __lowerCAmelCase = F"""https://api.giphy.com/v1/gifs/s...
368
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils imp...
207
0
"""simple docstring""" A: Dict = 8.314_4598 def _snake_case ( UpperCamelCase : float , UpperCamelCase : float ): if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <= 0: raise Exception("""Molar mass cannot be less ...
109
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def _snake_case ( UpperCamelCase : int = 1000000 , UpperCamelCase : int = 10 ): UpperCAmelCase : defaultdict = defaultdict(UpperCamelCase ) for outer_width in range(3 , (t_limit...
109
1
from __future__ import annotations def __snake_case ( _UpperCAmelCase ): __a = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements __a = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[0] and three[1] > three[2]: retur...
368
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, r...
131
0
'''simple docstring''' import os from math import logaa def lowerCAmelCase_ ( snake_case_ : str = "base_exp.txt" ) -> int: '''simple docstring''' UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path...
1
'''simple docstring''' import pprint import requests UpperCamelCase__ = '''https://zenquotes.io/api''' def a__ ( ) -> list: return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def a__ ( ) -> list: return requests...
181
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP"""...
370
'''simple docstring''' __lowerCAmelCase = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", """M""...
5
0
"""simple docstring""" def lowercase_ ( __UpperCAmelCase ) -> Optional[int]: if not head: return True # split the list to two parts lowerCAmelCase__ , lowerCAmelCase__ : List[str] = head.next, head while fast and fast.next: ...
242
"""simple docstring""" def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase = 0 ) -> list: lowerCAmelCase__ : Optional[Any] = length or len(__UpperCAmelCase ) lowerCAmelCase__ : int = False for i in range(length - 1 ): ...
242
1
import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() UpperCamelCase = l...
333
def lowercase_ ( _lowerCamelCase : list): for i in range(len(_lowerCamelCase) - 1 , 0 , -1): lowercase__ : int = False for j in range(_lowerCamelCase , 0 , -1): if unsorted[j] < unsorted[j - 1]: lowercase__ , ...
333
1
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavi...
231
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install...
148
0
def lowerCAmelCase_ ( UpperCamelCase_ = 1000000 ) -> int: UpperCamelCase_ = set(range(3 , __lowerCAmelCase , 2 ) ) primes.add(2 ) for p in range(3 , __lowerCAmelCase , 2 ): if p not in primes: ...
353
def lowerCAmelCase_ ( UpperCamelCase_ ) -> list: UpperCamelCase_ = int(UpperCamelCase_ ) if n_element < 1: UpperCamelCase_ = ValueError("a should be a positive number" ) raise my_error UpperCamelCase_ = ...
328
0
'''simple docstring''' import fire from utils import calculate_rouge, save_json def a_ ( _lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase=None ,**_lowerCAmelCase ) -> Dict: __lowerCamelCase : Any = [x.strip() for x in ...
208
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): lowercase__ = (CMStochasticIterativeScheduler,) lowercase__ ...
136
0
"""simple docstring""" __UpperCamelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def __SCREAMING_SNAKE_CASE ( A_ ): # Make sure the supplied data is a bytes-like object if not isinstance(A_ , A_ ): lowerCAmelCase__ : ...
366
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": __UpperCamelCase : int = '''%20'''.join(argv[1:]) if len(argv) > 1 else quot...
74
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_retribert import RetriBertTokenizer snake_case_ = logging.get_logger(__name__) snake_case_ = {'''vocab_f...
214
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''distilbert-base-uncased''': '''https://huggingface.co/distilbert-...
214
1
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger lowerCamelCase_ = get_logger(__name__) class __lowerCamelCase ( enum.Enum ): lowerCamelCase_ : Dict = 'all_checks' lowerCamelCas...
34
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedule...
34
1
import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_staging_te...
39
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowerCamelCase ( snake_case__): ...
39
1
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES _snake_case = logging.get_logger(__name__) _snake_case = OrderedDict( [ # Base model mapping ...
354
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json" ), } class ...
343
0
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo A ='\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yo...
34
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """facebook/data2vec-text-base""": """http...
58
0
from __future__ import annotations from statistics import mean def lowerCamelCase__ ( a , a , a ) -> list[int]: _A: List[str] = [0] * no_of_processes _A: Dict = [0] * no_of_processes # Initialize remaining_time to waiting_time. for i in range(a ): _...
301
def lowerCamelCase__ ( a = 10 ) -> str: if not isinstance(a , a ) or n < 0: raise ValueError('''Invalid input''' ) _A: int = 10**n _A: List[Any] = 2_84_33 * (pow(2 , 7_83_04_57 , a )) + 1 return str(number % modulus ) if __name__ == "__main__": ...
301
1
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate fr...
296
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class a__( nn.Module ): def __init__( self : Any , __snake_case : int = 16 , __snake_case : int = 88 , __snake_...
297
0
'''simple docstring''' class UpperCAmelCase : '''simple docstring''' def __init__( self ) -> List[str]: lowercase__ : Dict = {} def _lowerCAmelCase( self ) -> None: print(self.vertex ) for i in self.vertex: print(__lowe...
214
'''simple docstring''' 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 __UpperCamelCase ( Uppe...
214
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __lowercase ( UpperCAmelCase_ ): """simple docstring""" def _SCREAMING_SNAKE_CASE ( self : List[str] , lowerCAmelCase__ : flo...
13
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def _lowerCAmelCase ( __snake_case : Optional[Any] , __snake_case : Optional[i...
190
0
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler,...
371
"""simple docstring""" from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embe...
132
0
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transforme...
242
"""simple docstring""" from __future__ import annotations def lowercase_ ( __UpperCAmelCase ) -> int: if not nums: return 0 lowerCAmelCase__ : List[Any] = nums[0] lowerCAmelCase__ : List[str] = 0 for num in nums[1:]: ...
242
1
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDetection from t...
364
from math import pi, sqrt def __UpperCamelCase ( lowerCAmelCase__ : float ): if num <= 0: raise ValueError('''math domain error''' ) if num > 1_71.5: raise OverflowError('''math range error''' ) elif num - int(lowerCAmelCase__ ) not in (0, 0.5): raise NotImplementedError('''num ...
90
0
def a_ ( __lowercase : float , __lowercase : float ) -> float: if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(__lowercase ) * abs(__lowercase ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
282
import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sentencepiece @require_token...
282
1
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def snake_case_(_UpperCamelCase ) -> ...
278
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils import is...
278
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """google/bigbird-roberta-base""": """https://h...
140
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """huggingface/time-series-transformer-tourism-monthly""": ( """https://huggingface.co/huggin...
140
1
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( IMAG...
354
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->Tuple: _enforce_args(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) if n == 0: return 0 a__: List[Any] = float('-inf' ) for i in range(1 , n + 1 ...
203
0
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) fro...
242
"""simple docstring""" from typing import Any import numpy as np def lowercase_ ( __UpperCAmelCase ) -> bool: return np.array_equal(__UpperCAmelCase , matrix.conjugate().T ) def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> Any: ...
242
1
from __future__ import annotations lowerCAmelCase = [-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0] lowerCAmelCase = [-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1] def _lowerCamelCase( lowercase__ ) -> list[float]: '''simple docstring''' ...
304
from __future__ import annotations import numpy as np def _lowerCamelCase( lowercase__ ) -> str: '''simple docstring''' return np.maximum(0 , lowercase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
304
1
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, ConditionalDet...
90
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class lowerc...
222
0
import sys def A (__A : int ) -> Dict: """simple docstring""" UpperCAmelCase_ = len(__A ) UpperCAmelCase_ = [[0 for x in range(__A )] for x in range(__A )] UpperCAmelCase_ = [[0 for x in ra...
352
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
7
0
'''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, DISTILBERT_PRETRA...
321
'''simple docstring''' 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...
321
1
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: float ): '''simple docstring''' return 10 - x * x def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: float , __lowerCamelCase: float ): '''simple docstring''' if equation(__lowerCamelCase ...
362
import sys def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: Optional[Any] ): '''simple docstring''' lowercase_ = len(__lowerCamelCase ) lowercase_ = [[0 for x in range(__lowerCamelCase )] for x in range(__lowerCamelCase )] lowercase_ = [[0 ...
297
0
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset from to...
253
lowerCAmelCase : str = '0.21.0' from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batches...
253
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''} class __snake_case ( low...
366
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __snake_case = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LlamaConfig'''],...
78
0
a__ = """Tobias Carryer""" from time import time class snake_case : '''simple docstring''' def __init__( self : Tuple , lowerCAmelCase : Dict , lowerCAmelCase : Optional[int] , lowerCAmelCase : Tuple , lowerCAme...
317
from ...processing_utils import ProcessorMixin class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case_ : int = ["""image_processor""", """feature_extractor"""] snake_case_ : List[Any] = """T...
317
1
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow ...
364
'''simple docstring''' def lowercase (_A = 1_0_0_0_0_0_0 ): """simple docstring""" _lowerCAmelCase : Any = set(range(3 , _A , 2 ) ) primes.add(2 ) for p in range(3 , _A , 2 ): ...
25
0
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: if not isinstance(__snake_case, __snake_case ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" ) return sum...
162
"""simple docstring""" import argparse import os import re import packaging.version __A : List[str] = '''examples/''' __A : int = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), ...
33
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic...
255
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: if not i...
255
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow,...
34
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, requi...
341
0
# 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 ( C...
33
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A : Optional[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDepend...
33
1
_UpperCAmelCase : Dict = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDow...
50
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase : Any = logging.get_logger(__name__) lowerCAmelCase : Tuple = ...
13
0
class A__ : """simple docstring""" def __init__( self) -> Optional[Any]: '''simple docstring''' a__ : Any = {} def __lowercase ( self) -> None: '''simple docstring''' print(self.vertex) ...
225
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase : List[str] = { """configuration_clip""": [ ...
225
1
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 lowercase ( lowercase_ , unittest.TestCase ): __SCRE...
285
from PIL import Image def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' snake_case_ = (259 * (level + 255)) / (255 * (259 - level)) def contrast(UpperCamelCase__ ) -> int: return int(128 + factor *...
285
1
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class __lowerCAmelCase ( lowerCAmelCase): _a = CustomTokenizer pass
158
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import Con...
158
1
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_se...
71
import re def A ( a_ ) -> bool: __UpperCamelCase : Any =re.compile( r'^(?:0|94|\+94|0{2}94)' r'7(0|1|2|4|5|6|7|8)' r'(-| |)' r'\d{7}$' ) return bool(re.search(a_ ,a_ ) ) if __name__ == "__main__": ...
71
1
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp ...
16
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCamelCase = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_...
16
1