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 copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class _a : """simple docstring""" UpperCamelCase__ = None UpperCamelCase__ = False UpperCamelCase__ = ...
149
import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib A__: Optional[int] ...
149
1
from typing import Any def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" if not input_list: return [] lowercase__ : Union[str, Any] = [input_list.count(lowerCamelCase__ ) for value in input_list] lowercase__ : Dict ...
121
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''KEY''') lowerCAmelCase__ = TypeVar('''VAL''') @dataclass(frozen=_UpperCamelCase , slots=_UpperCamelCase ) class snake_case__(Gener...
121
1
lowercase__ : Union[str, Any] = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is...
328
'''simple docstring''' import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowerCAmelCase__ : lowerCAmelCase_ = None def _snake_case ( self ): """simple docst...
93
0
import random from typing import Any def lowerCamelCase_ ( _a ): """simple docstring""" for _ in range(len(_snake_case ) ): lowerCAmelCase__ : Any = random.randint(0 , len(_snake_case ) - 1 ) lowerCAmelCase__ : Optiona...
369
# using dfs for finding eulerian path traversal def lowerCamelCase_ ( _a , _a , _a , _a=None ): """simple docstring""" lowerCAmelCase__ : Optional[Any] = (path or []) + [u] for v in graph[u]: if visited_edge[u][v...
211
0
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, T...
236
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer...
137
0
'''simple docstring''' from __future__ import annotations import numpy as np def UpperCamelCase_( snake_case : list[float] ): '''simple docstring''' return np.maximum(0 , snake_case ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # -->...
358
'''simple docstring''' def UpperCamelCase_( snake_case : int = 1_0_0_0 ): '''simple docstring''' snake_case_ = 3 snake_case_ = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a %...
92
0
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet....
239
'''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.0 # # U...
239
1
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...
369
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remot...
26
0
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, ...
21
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @...
110
0
"""simple docstring""" from collections.abc import Callable def lowercase ( lowerCAmelCase__ : Callable[[float], float] , lowerCAmelCase__ : float , lowerCAmelCase__ : float ) -> float: __a = a __a = b if function(lowerCAmelCas...
358
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiec...
11
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : List[Any] = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextConfig''', ...
94
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regr...
94
1
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...
350
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampli...
171
0
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class __A : _UpperCamelCase : torch.Tensor # [batch_size x 3] _UpperCamelCase : torch.Tensor # [batch_size x 3] _UpperCamelCase : torch.T...
44
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(): from PIL import Im...
340
0
"""simple docstring""" import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( Autoe...
209
"""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.0...
209
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase_ = { """configuration_graphormer""": ["""GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GraphormerConfig"""], } try: if not is_torch_ava...
303
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=logging.INFO ) lowerca...
303
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case__ ( snake_case_ ...
268
"""simple docstring""" def _lowerCamelCase( a ): __a = len(a ) for i in range(1 , a ): __a = collection[i] __a = 0 __a = i - 1 while low <= high: __a = ...
268
1
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
227
import random def a( A : Optional[Any] , A : Optional[Any] , A : str ) -> List[Any]: """simple docstring""" a = a[left_index] a = left_index + 1 for j in range(left_index + 1 , A ): if a...
227
1
'''simple docstring''' def _lowerCamelCase ( lowerCamelCase_ : int ): """simple docstring""" UpperCAmelCase_ : str = len(lowerCamelCase_ ) while cur > 1: # Find the maximum number in arr UpperCAmelCase_ : Optional[Any]...
274
'''simple docstring''' import os import time import numpy as np import onnxruntime as ort snake_case__ : Optional[int] = '''1''' snake_case__ : str = '''0''' snake_case__ : List[str] = '''1''' snake_case__ : List[str] = ort.SessionOptions...
274
1
'''simple docstring''' a : Tuple = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } def lowercase ( __magic_name__ , __magic_name__ , __magic_name__ ): '''simp...
311
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForSeqaSeqLM @...
130
0
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class _a ( _lowerC...
128
"""simple docstring""" import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class _a ...
128
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowercase = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LayoutLMv2Con...
43
import os def _A ( ) -> Tuple: """simple docstring""" with open(os.path.dirname(_lowercase ) + '/p022_names.txt' ) as file: __UpperCamelCase = str(file.readlines()[0] ) __UpperCamelCase = names.replace...
310
0
"""simple docstring""" from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function lowerCamelCase__ = 1.0_5457_1817E-34 # unit of ℏ : J * s lowerCamelCase__ = 3E8 # unit of c : m * s^-1 def ...
310
"""simple docstring""" lowerCamelCase__ = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def lowercase__ ( lowercase_ ,lowercase_ ,lowercase_ ,lowercase_ ) -> ...
310
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __lowerCAmelCase ( __snake_case ): _a = (DDPMScheduler,) def A__ ( self , **lowerCAmelCase ) -> Any: '''simple docstring''' ...
205
"""simple docstring""" from typing import Any class a : def __init__( self : Tuple , __SCREAMING_SNAKE_CASE : Any ) -> List[Any]: lowerCamelCase_ = data lowerCamelCase_ = ...
183
0
"""simple docstring""" import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers imp...
371
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline a =argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) parser.add_argument("""--dpm""", action="""store_true""",...
113
0
def SCREAMING_SNAKE_CASE__ ( __a = 10_00 ): snake_case_ ,snake_case_ : List[str] = 1, 1 snake_case_ : Optional[Any] = [] for i in range(1 , n + 1 ): snake_case_ : List[Any] = prev_numerator + 2 * prev_denominator snake_case_ :...
327
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :str , lowerCAmelCase__ :Optional[Any] ) -> int: '''simple docstring''' lowercase = [0 for i in range(r + 1 )] # nc0 = 1 lowercase = 1 for i in range...
197
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self : Dict , _lowerCAmelCase ...
370
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def UpperCAmelCase_ ( __UpperCAmelCase : List[str] ) -> List[Any]: # vision encoder if "img_encoder.pos_embed" in name: SCRE...
210
0
"""simple docstring""" from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ...
136
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState ...
136
1
def _snake_case( SCREAMING_SNAKE_CASE__ : list ) -> float: '''simple docstring''' A__ = 0 while len(_UpperCamelCase ) > 1: A__ = 0 # Consider two files with minimum cost to be merged for...
359
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowercase_ = Path(__file__).resolve().parents[3] / "src" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import i...
282
0
"""simple docstring""" import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ....
171
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , low...
171
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowerCamelCase...
364
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, re...
135
0
'''simple docstring''' from maths.prime_factors import prime_factors def snake_case ( UpperCAmelCase )-> int: """simple docstring""" if not isinstance(UpperCAmelCase , UpperCAmelCase ): __A = f'Input value of [number={number}...
161
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings...
161
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, is_vision_available, ) lowerCamelCase = ...
370
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/conf...
241
0
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig 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_config...
46
"""simple docstring""" import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE__ = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" SCREAMING_SNAKE_CASE__ = "\...
46
1
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_v...
365
from math import pow def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , ): if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. ...
194
0
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __snake_case :Dict = logging.getLogger(__name__) def __snake_case ( ): __a = argparse.ArgumentParser( description='''Prepare TFRecord sha...
49
from ... import PretrainedConfig _SCREAMING_SNAKE_CASE : Dict = { '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''', } class UpperCAmelCase__ ( A__ ): """simple docstring""" a = NEZHA_PRETRAINE...
314
0
from __future__ import annotations import numpy as np def UpperCamelCase ( __lowercase : np.ndarray ): '''simple docstring''' A_ , A_ : Optional[int] = np.shape(__lowercase ) if rows != columns: A_ : Union[str, Any] = ( ...
192
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) # # order specific notes: # - tqdm must be checked befor...
192
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ ...
12
"""simple docstring""" def lowercase (_lowerCAmelCase = 100_0000 ): __lowerCAmelCase = 1 __lowerCAmelCase = 1 __lowerCAmelCase = {1: 1} for inputa in range(2 , _lowerCAmelCase ): __lowerCAmelCase = 0 __lowerCA...
301
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _lowerCamelCase : List[str] = logging.get_logger(__name__) class __UpperCAmelCase ( A__ ): '''simple docstring''' def __init__(self : Un...
337
'''simple docstring''' def __a ( UpperCAmelCase , UpperCAmelCase ) ->Tuple: """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(UpperCAmelCase , int(b / 2 ) ) * actual_power(UpperCAmelCase , int(b / 2 ) ) else:...
337
1
from __future__ import annotations from math import pi, sqrt def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> Optional[int]: """simple docstring""" if inductance <= 0: raise ValueError("""Inductance cannot be 0 or negative""" ) elif capacitance <= ...
116
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_fne...
131
0
"""simple docstring""" import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet,...
362
"""simple docstring""" __snake_case : Any = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66...
58
0
"""simple docstring""" import requests __snake_case = '''YOUR API KEY''' def A_ ( _lowerCAmelCase : str, _lowerCAmelCase : str = giphy_api_key ): """simple docstring""" _a = '''+'''.join(query.split() ) _a = f'https://api.giphy.com/v1/gifs/s...
320
"""simple docstring""" from __future__ import annotations def A_ ( _lowerCAmelCase : float, _lowerCAmelCase : float, _lowerCAmelCase : float, ): """simple docstring""" if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You c...
320
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_im...
357
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __magic_name__ = { "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, "num_class_embed...
255
0
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer snake_case__ : Optional[Any] = logging.getLogger(__name__) def _a ( ) -> int: '''simple docstring''' ...
117
from itertools import permutations def _a ( lowerCamelCase: tuple ) -> bool: '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: ...
117
1
from math import factorial def a( A : int , A : int ) -> int: """simple docstring""" if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n >= k" ) return factorial(A ) // (factorial(A ) * factorial(n - k )) if __name__ == "__ma...
71
def a( A : int = 200 ) -> int: """simple docstring""" a = [1, 2, 5, 10, 20, 50, 100, 200] a = [0] * (pence + 1) a = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(A , pence + 1 , 1 ): ...
71
1
"""simple docstring""" import copy import re class __UpperCamelCase : lowerCamelCase : Optional[int] ='''hp''' lowerCamelCase : Any ={} lowerCamelCase : Any =None @classmethod def ...
105
import re def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : List[Any] = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(_A, _A ): return match.string == phone return False if __nam...
342
0
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class...
271
"""simple docstring""" import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available a = logging.getLogger(__name__) @da...
271
1
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __UpperCamelCase : List[str] ...
146
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class _UpperCAmelCase ( A__ ): """simple docstring""" def __init__( self ...
207
0
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKI...
207
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean _snake_case : Dict = 0 _snake_case : Dict = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, ...
207
1
"""simple docstring""" 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 from flax....
17
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sq...
276
0
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path a__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) a__ : list[int] = [ord...
243
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lice...
243
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowerCamelCase : Any = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwiftFormerConfig''', ...
219
# 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 required...
219
1
from typing import Any class UpperCamelCase : def __init__( self , UpperCAmelCase__ ): A__ = data A__ = None def __repr__( self ): return F"""Node({self.data})""" class UpperCamelCase : def __init__( self ): ...
198
import math def UpperCamelCase ( _A : float , _A : float )-> float: """simple docstring""" if ( not isinstance(_A , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("pow...
198
1
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' _UpperCAmelCase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4)) ...
260
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __A : int = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def lowercase ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE ...
260
1
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline a__ = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does not use value network '''scale_gra...
15
# 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 ...
15
1
def _UpperCAmelCase (UpperCamelCase__ : int = 2000000 ): _A : Tuple = [0 for i in range(n + 1 )] _A : Union[str, Any] = 1 _A : Optional[Any] = 1 for i in range(2 , int(n**0.5 ) + 1 ): ...
11
def _UpperCAmelCase (UpperCamelCase__ : str , UpperCamelCase__ : bool = False ): if not isinstance(UpperCamelCase__ , UpperCamelCase__ ): _A : Optional[Any] = f"Expected string as input, found {type(UpperCamelCase__ )}" ...
11
1
"""simple docstring""" from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __lowerCAmelCase ( ...
11
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} ...
11
1
"""simple docstring""" import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets _snake_case : Optional[int] = '\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burn...
292
import argparse import os import re lowercase_ = 'src/transformers' # Pattern that looks at the indentation in a line. lowercase_ = re.compile(R'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. lowercase_ = re.compile(R'^\s*"([^"]+)":') # Pattern that...
205
0
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers.mod...
19
def UpperCAmelCase_( a__ ): """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE : Tuple = 1 SCREAMING_SNAKE_CASE : Tuple = 1 while repunit: SCREAMING_SNAKE_CASE : ...
19
1
import math class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_=0 ) -> int: # a graph with Node 0,1,...,N-1 __UpperCamelCase =n __UpperCamelCase =[ [math.inf for j in range(0 , A_ )] fo...
62
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase = { '''configuration_altclip''': [ '''ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AltCLIPConfig''', '''...
306
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : List[Any] = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''', ''...
70
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : List[Any] = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Fun...
70
1
'''simple docstring''' def _lowerCamelCase ( lowercase : bytes ) -> str: return "".join([hex(lowercase )[2:].zfill(2 ).upper() for byte in list(lowercase )] ) def _lowerCamelCase ( lowercase : str ) -> bytes: # Check data validity, fol...
63
'''simple docstring''' from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from ...
63
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Union[str, Any] = { "configuration_pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"], } try: if not is_torch_available(): ...
352
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...t...
347
0
"""simple docstring""" 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(...
25
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_safe ...
252
0
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blend...
359
import math from collections.abc import Iterator from itertools import takewhile def UpperCAmelCase_( a__ ): """simple docstring""" 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 ...
19
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common im...
18
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase : Union[str, Any] = { '''configuration_chinese_clip''': [ '''CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ChineseCLIPConfig''...
18
1
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": lowercase__ = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path"...
83
'''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 .embeddings_flax ...
83
1
"""simple docstring""" import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import ...
98
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class snake_case : SCREAMING_SNAKE_CASE_ : Optional[Union[str, Path]] = None SCREAMING_SNAKE_CASE_ : bool ...
217
0
'''simple docstring''' import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common imp...
16
'''simple docstring''' 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, ) _UpperCamelCase = { '...
16
1
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class __SCREAMING_SNAKE_CASE ( lowerCamelCase_ ): def __init__...
337
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class lowerCAm...
346
0
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping UpperCAmelCase_ : Union[str, Any] = tuple[int, int] class lowerCAmelCase__ : '''simple docstring''' def __init__(...
358
"""simple docstring""" import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_...
318
0
"""simple docstring""" import functools from typing import Any def lowercase (snake_case__ : str , snake_case__ : list[str] ) -> bool: '''simple docstring''' if not isinstance(__lowercase , __lowercase ) or len(__lowercase ...
155
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : str ) -> str: '''simple docstring''' return " ".join( "".join(word[::-1] ) if len(__lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": im...
22
0
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket") @patch("builtins.open") def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : str): # ===== initialization ===== lowercase__ : Union[str, Any] = ...
356
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__A ) class snake_case_ ( __A ): # `task` is not a ClassVar since we want it to be part of the `asdict` output f...
333
0
'''simple docstring''' 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 = { '''junnyu/roform...
37
'''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_availab...
37
1
'''simple docstring''' 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 imp...
72
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a : int = { 'configuration_xlm': ['XLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMConfig', 'XLMOnnxConfig'], 'tokenization_xlm': ['XLMToken...
72
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, ...
126
"""simple docstring""" import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_avai...
126
1
"""simple docstring""" import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-s...
367
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not...
62
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase : Any = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_...
42
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
1
"""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_gr...
144
"""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.0 # ...
144
1
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transfor...
70
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer lowerCAmelCase_ = {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''...
8
0
"""simple docstring""" import argparse from collections import defaultdict import yaml _lowerCAmelCase : Optional[Any] = "docs/source/en/_toctree.yml" def __snake_case ( SCREAMING_SNAKE_CASE__ : List[str] ) -> Dict: '''simple docstring''' _Uppe...
355
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTes...
202
0
from sklearn.metrics import matthews_corrcoef import datasets _lowercase: Any = '\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true and...
227
def __UpperCamelCase ( _A : Dict ) ->List[str]: """simple docstring""" lowerCamelCase_ =[0] * len(_A ) lowerCamelCase_ =[] lowerCamelCase_ =[] lowerCamelCase_ =0 for values in graph.values(): for i in ...
154
0
import inspect import unittest from transformers import YolosConfig 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 ...test_model...
355
import argparse import struct import unittest class UpperCamelCase : def __init__( self , UpperCAmelCase__ ): A__ = data # Initialize hash values A__ = [ 0x6A_09E_667, 0xBB_67A_E85, 0x3C_6EF_372, 0xA...
198
0
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( """files""",[ ["""full:README.md""", """dataset_infos.json"""], ["""empty:README.md""", """dataset_infos.json"""]...
26
"""simple docstring""" from __future__ import annotations from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self : Any, UpperCAmelCase__ : int ): __lowercase = num_of_nodes __lowercase = [] __lo...
17
0
"""simple docstring""" class lowerCamelCase_: '''simple docstring''' def __init__( self , lowerCamelCase__ , lowerCamelCase__ ): _lowerCamelCase = name _lowerCamelCase = val def __str__( self ): return F"""{self.__class__.__...
357
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Dict = { '''alibaba-damo/mgp-str-base''': '''https://huggingface.co/alibaba-damo/mgp-s...
73
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :int = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :List[Any] = { '''microsoft/unispeech-large-1500h-cv''': ...
22
'''simple docstring''' 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 ...
22
1
'''simple docstring''' from bisect import bisect from itertools import accumulate def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ )-> Optional[Any]: '''simple docstring''' _UpperCAmelCase : Any = sort...
349
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowercase : """simple docstring""" UpperCAmelCase = 42 UpperCAmelCase = 42 class ...
349
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx....
93
'''simple docstring''' from jiwer import compute_measures import datasets lowercase__ = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: impr...
151
0
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor ...
313
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : lowercase__ = None lowercase__ = False lowercase__ = False lowercase__ ...
313
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __A = {"configuration_vit_mae": ["VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMAEConfig"]} try: ...
177
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import...
177
1
'''simple docstring''' from __future__ import annotations def _lowercase ( __A ,__A ): '''simple docstring''' if partitions <= 0: raise ValueError("""partitions must be a positive number!""" ) if partitions > number_of_bytes: raise ValueError("""p...
243
'''simple docstring''' import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def _lowercase ( __A ,__A ,__A ,__A ): '''simple docstring''' __UpperCamelCase = s.rsplit(__A ...
243
1
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowercase_ = logging.get_logger(__name__) ...
45
"""simple docstring""" from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase__ ...
290
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
130
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, Auto...
130
1
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness a_ = '''\ @misc{chen2021evaluating, title...
152
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _SCREAMING_SNAKE_CASE : List[Any] ...
183
0
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to conv...
359
"""simple docstring""" def __A ( a_ :int) -> Union[str, Any]: __a : int = [] __a : Dict = [] __a : str = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, ...
188
0
'''simple docstring''' from math import ceil def _UpperCamelCase ( __A , __A ) -> Tuple: '''simple docstring''' UpperCamelCase__ = list(range(0 , __A ) ) UpperCamelCase__ = [item for sublist in list(device_map.value...
80
'''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.0...
80
1
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): if not all(char in '''01''' for char in bin_string ): raise ValueError('''Non-binary value was passed to the function''' ) if not bin_string: raise ValueError('''Empty string was passed to the function''' ) lowercase__ ...
370
'''simple docstring''' def __UpperCamelCase ( ): lowercase__ : Any = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] lowercase__ : Any = 6 lowercase__ : Optional[Any] = 1 lowercase__ : int = 1901 lowercase__ : List[str] = 0 while year < 2001: da...
214
0
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, torch_device fro...
333
import math def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> float: '''simple docstring''' if ( not isinstance(SCREAMING_SNAKE_CASE , (int, float) ) or power_factor < -1 or power_factor > 1 ): ra...
333
1
"""simple docstring""" import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def snake_case (A_ :Union[dict, list, tuple, torch.Tensor] ...
186
"""simple docstring""" import os import sys _UpperCamelCase : str = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Auto...
186
1
def lowerCamelCase__ ( snake_case_ : list ) -> list: if len(snake_case_ ) <= 1: return lst __snake_case = 1 while i < len(snake_case_ ): if lst[i - 1] <= lst[i]: i += 1 else: __snake_case , __sn...
24
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_...
24
1
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _A ( UpperCamelCase_ : Dict) -> Optional[int]: '''simple docstring''' __lowercase = os.path.join(args.tf_model_dir...
144
"""simple docstring""" from __future__ import annotations from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self : Union[str, Any], UpperCAmelCase__ : int ): __lowercase = num_of_nodes __lowercase =...
144
1