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
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : Tuple = { 'configuration_roformer': ['R...
347
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) f...
347
1
"""simple docstring""" from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAtten...
363
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :float , snake_case_ :float , snake_case_ :float ): if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: raise Va...
86
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMSchedule...
98
'''simple docstring''' def snake_case_ ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" _SCREAMING_SNAKE_CASE : str = 0 for ch in input_str: _SCREAMING_SNAKE_CASE : Optional[Any] = ord(SCREAMING_SNAKE_CASE__ ) _SCREAMING_SNAK...
200
0
"""simple docstring""" import numpy as np __SCREAMING_SNAKE_CASE : Optional[int] = [ ['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'k'], ['l', 'm', 'n', 'o', 'p'], ['q', 'r', 's', 't', 'u'], ['v', 'w', 'x', 'y', 'z'], ] class __A : '''simple d...
233
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> int: assert column_title.isupper() snake_case_ = 0 snake_case_ = len(_SCREAMING_SNAKE_CASE ) - 1 snake_case_ = 0 while index >= 0: snake_case_ ...
233
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, to_channel_di...
341
'''simple docstring''' from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.sched...
341
1
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class UpperCAmelCase ( unittest.TestCase ): def UpperCAmelCase_ ( self :Optional[Any] )-> Any: ...
123
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __lowerCAmelCase : List[str] =logging.get_logger(__name__) def UpperCamelCase ( _lo...
123
1
'''simple docstring''' import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _SCRE...
158
'''simple docstring''' from __future__ import annotations def __a(SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ): '''simple docstring''' if days_between_payments <= 0: raise ValueError("days_betwe...
158
1
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Traini...
356
import numpy class UpperCAmelCase : '''simple docstring''' def __init__( self : List[str] ,A : numpy.ndarray ,A : numpy.ndarray ): __A = input_array # Random initial weights are assigned where first argument is the # number of nodes in previou...
124
0
import numpy as np import torch from ..models.clipseg import CLIPSegForImageSegmentation from ..utils import is_vision_available, requires_backends from .base import PipelineTool if is_vision_available(): from PIL import Image class __lowercase (_lowerCamelCase ): _UpperCamelCase = ( 'Thi...
275
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
86
0
"""simple docstring""" def __lowercase ( _a ): if len(_a ) <= 1: return [tuple(_a )] snake_case_ : List[str] = [] def generate(_a , _a ): snake_case_ : Optional[int] = [0] * n res.append(tuple(_a ) ) snake_case_ ...
362
"""simple docstring""" from collections.abc import Generator def __lowercase ( ): snake_case_, snake_case_ : List[str] = 0, 1 while True: snake_case_, snake_case_ : List[str] = b, a + b yield b def __lowercase ( _a = 1_000 ):...
155
0
from __future__ import annotations from fractions import Fraction def snake_case_ ( lowerCAmelCase_ : int , lowerCAmelCase_ : int ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def snake_case_ ( lowe...
233
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def snake_case_ ...
233
1
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
34
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.ut...
34
1
_snake_case : Any = range(2, 20 + 1) _snake_case : str = [10**k for k in range(ks[-1] + 1)] _snake_case : dict[int, dict[int, list[list[int]]]] = {} def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelC...
123
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _snake_case : Optional[Any] = logging.get_logger(__name__) class a (_lowerCAmelCase ): """simple docstring""" def __init__( self : Optional[Any] , *lowerCa...
123
1
"""simple docstring""" def _a ( _snake_case ): """simple docstring""" UpperCAmelCase = 0 UpperCAmelCase = len(_snake_case ) for i in range(n - 1 ): for j in range(i + 1 , _snake_case ): if a...
234
"""simple docstring""" from __future__ import annotations def _a ( _snake_case , _snake_case , _snake_case ): """simple docstring""" if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0""" ...
234
1
"""simple docstring""" __UpperCamelCase = 6_5521 def UpperCAmelCase ( UpperCAmelCase ) -> int: snake_case_ = 1 snake_case_ = 0 for plain_chr in plain_text: snake_case_ = (a + ord(UpperCAmelCase )) % MOD_ADL...
69
from typing import Union import fire import torch from tqdm import tqdm def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase = "cpu" ,lowercase = None ) -> None: snake_case : int = torch.load(lowercase ,map_location=lowercase ) for k, v in tqdm(state_...
124
0
"""simple docstring""" import math def lowercase ( _snake_case : int ) ->bool: """simple docstring""" assert isinstance(_snake_case , _snake_case ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
358
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: impo...
24
0
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig __UpperCamelCase : List[str] = logging.get_logger(__name__) class SCREAMIN...
106
"""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 SCREAMING_SNAKE_CASE__ ( _a ): _a = field(default='i...
155
0
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> int: if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < 0: raise ValueError("""multiplicative_pers...
353
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional @dataclass class __A : '''simple docstring''' __lowercase: Optional[str] = field( default="""codeparrot/codeparrot""" , metadata={"""help""": """Model na...
233
0
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging A =logging.get_logger(__name__) A ={ 'facebook/encodec_24khz': 'https://huggingface.co/facebook/encodec_24khz/resolve/main/confi...
34
'''simple docstring''' import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow A =[ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classification',...
34
1
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ) -> int: '''simple docstring''' if index == number_of_items: return 0 lowerCAmelCase : Tuple = 0 lowerCAmelCase : Tuple =...
323
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : List[Any] = { '''configuration_xlm_roberta'''...
323
1
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( Uppe...
234
'''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(...
234
1
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : List[str] = {...
361
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class UpperCamelCas...
252
0
'''simple docstring''' from __future__ import annotations from typing import Any class __UpperCamelCase : def __init__( self, lowerCAmelCase, lowerCAmelCase, lowerCAmelCase = 0 ): """simple docstring""" lowerCamelCase_, lowerCamelCase...
75
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
0
import qiskit def A_ ( A__ , A__ ) -> qiskit.result.counts.Counts: a__ : Tuple = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register a__ : str = qiskit.QuantumCircuit(A__ , A__ ) ...
369
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, ...
225
0
def snake_case_ ( lowerCAmelCase_ : dict ): __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() return any( node not in visited and dep...
233
# 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 ...
233
1
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, requi...
360
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class UpperCamelCase_ (unittest.TestCase ): def _SCREAMING_SNAKE_CASE ( ...
253
0
'''simple docstring''' def __A ( lowerCamelCase_ = 10**9 ): """simple docstring""" SCREAMING_SNAKE_CASE : int = 1 SCREAMING_SNAKE_CASE : str = 2 SCREAMING_SNAKE_CASE : int = 0 SCREAMING_SNAKE_CASE : A...
323
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import Model...
323
1
import random class UpperCAmelCase__ : """simple docstring""" @staticmethod def _a ( A_ ) -> tuple[list[int], list[int]]: __UpperCamelCase =[ord(A_ ) for i in text] __UpperCamelCase =[] __UpperCamelCase =[] for i i...
117
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
117
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() ...
245
def __lowerCamelCase ( lowerCamelCase__ : Any , lowerCamelCase__ : Optional[int] ): '''simple docstring''' return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __lowerCamelCase ( lowerCamelCase__ : List[str] , lowerCamelCase__ ...
252
0
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import ...
354
import logging from transformers.configuration_utils import PretrainedConfig lowerCamelCase_ = logging.getLogger(__name__) class __lowerCamelCase ( __snake_case ): lowerCamelCase_ : Optional[int] = 'masked_bert' def __init__( self , lowerCam...
34
0
import glob import os import random from string import ascii_lowercase, digits import cva _lowerCAmelCase : Tuple = '' _lowerCAmelCase : Optional[Any] = '' _lowerCAmelCase : Any = '' _lowerCAmelCase : Optional[int] = 1 # (0 is vertical, 1 is horizon...
169
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer lowerCamelCase__ : Union[str, Any] = logging.get_logger(__na...
225
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def _A ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : Dict=False ): """simple docstring""" a__ : Optional[int] =OmegaCon...
364
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import A...
148
0
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import...
4
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Any = ...
253
0
"""simple docstring""" from __future__ import annotations UpperCAmelCase_ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowerCamelCase__: def __init__( self: Tuple ...
353
UpperCAmelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCAmelCase_ = ['a', 'b', 'c', 'd', 'e'] def lowerCamelCase__ ( A__ : Union[str, Any] , A__ : Optional[int] , A__ : str ): '''simple docstring''' __lowerCamelCase ...
29
0
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from...
117
import argparse import copy def _a ( lowerCamelCase: List[Any] ) -> List[str]: '''simple docstring''' __A = {} with open(lowerCamelCase ) as f: for line in f: if line.split()[0] not in dict_of_neig...
117
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 ( SegformerConfig, SegformerForImageClassification, SegformerForSemanticSegmentation, Se...
362
import warnings from functools import wraps from typing import Callable def SCREAMING_SNAKE_CASE__ ( lowercase ) -> Callable: @wraps(lowercase ) def _inner_fn(*lowercase ,**lowercase ): warnings.warn( (f"""'{fn.__name__}' is experimental and might be subje...
176
0
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFe...
48
'''simple docstring''' from ..utils import DummyObject, requires_backends class _a ( metaclass=__a ): __a : int = ["""flax""", """transformers"""] def __init__( self : Optional[Any] , *lowercase : str , **lowercase : List[Any] ): ...
34
0
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import ...
32
"""simple docstring""" 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...
32
1
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments lowerCAmelCase__ :Dict = logging.getLogger(__name__) @dataclass class __a ( lowerCamelCase_ ): _a : Optional[floa...
329
"""simple docstring""" import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __A = { "facebook/mask2former-swin-small-coco-instance": ( "https://huggingface....
148
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __UpperCAmelCase =2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that ...
354
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ ) -> str: __lowerCamelCase = [] __lowerCamelCase = set({'''(''', '''[''', '''{'''} ) __lowerCamelCase = set({''')''', ''']''', '''}'''} ) __lowerCamelCase = {'''{''': '''}'''...
237
0
"""simple docstring""" def __lowerCAmelCase ( lowercase : int = 400_0000 ) -> Any: """simple docstring""" snake_case : int = [0, 1] snake_case : List[str] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if ...
203
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess...
29
0
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB 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.apa...
364
'''simple docstring''' 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_ou...
322
0
'''simple docstring''' from collections.abc import Sequence def a ( __a = None ) -> int: '''simple docstring''' if nums is None or not nums: raise ValueError('''Input sequence should not be empty''' ) UpperCamelCase__ :Optional[Any] = nums[0] for ...
97
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTokenizer __snake_ca...
176
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging __A =logging.get_logger(__name__) __A ={ 'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json', # See all M-CTC-T models at https://huggingface....
363
'''simple docstring''' import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _snake_case ( unittest.TestCase ): def snake_case__ ( self): UpperCAmelCase__ : ...
283
0
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger UpperCAmelCase_ : Optional[int] = '<<<<<<< This should probably be modified because it mentions: ' Upp...
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 math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance lowerCamelCase__ = 637_8137.0 lowerCamelCase__ = 635_6752.31_4245 lowerCamelCase__ = 637_8137 def lowercase__ ( lowercase_ ,lowercase_ ,...
361
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def lowercase__ ( lowercase_ ,lowercase_ ,lowercase_ = 1 / sqrt(2 ) ) -> IIRFilter: """simple docstring""" _UpperCamelCase : Optional[Any] = ta...
310
0
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowerCAmelCase_ = argparse.ArgumentParser('Stable Diffusion script with intel optimization', add_help=Fal...
16
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black __lowerCAmelCase : Any =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402...
237
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json", # See all SEW-D models at htt...
300
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def A ( _lowerCamelCase = 8 ): '''simple docstring''' _lowerCAmelCase : Optional[int] = ascii_letters + digits + punctuation ...
300
1
from __future__ import annotations import typing from collections import Counter def __lowerCAmelCase ( a__ ) -> typing.Counter[int]: __a = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(a__ , max_perimeter + 1 ): ...
6
def _a ( SCREAMING_SNAKE_CASE : str ) -> Union[str, Any]: """simple docstring""" __lowerCAmelCase: str = len(SCREAMING_SNAKE_CASE ) __lowerCAmelCase: List[Any] = sum(SCREAMING_SNAKE_CASE ) __lowerCAmelCase: str = [[False for x in range(s + 1 )...
322
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ : Union[str, Any] = logging.get_logger(__name__) lowerCamelCase_ : List[Any] = { """google...
197
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : Optional[int] = {"""configuration_xlnet""": ["""XLNET_PRETRA...
197
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch if is_vision_availab...
6
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stab...
283
0
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline _A : int = version.parse(version.parse(to...
354
def _a ( UpperCAmelCase ) -> int: """simple docstring""" if not isinstance(UpperCAmelCase , UpperCAmelCase ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) lowerCamelCase__ : List[str] = 0 while number:...
265
0
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def __lowerCamelCase ( ) -> str: """simple docstring""" raise RuntimeErr...
274
def _A ( _lowercase ) -> list: """simple docstring""" def merge(_lowercase , _lowercase ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) ...
310
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/LI...
326
"""simple docstring""" import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Traine...
326
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironmen...
300
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) def __snake_case ( _lowerCAmelCase : int , _lowerCAmelCase : Any ) ...
300
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { 'transfo-xl-wt103': 'https://huggingface.co/transfo-xl-wt103/resolve/main/config.json', } class _lowerCAmelCase ( lowercase ...
362
"""simple docstring""" import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <us...
144
0
"""simple docstring""" import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_tes...
197
"""simple docstring""" from ..utils import DummyObject, requires_backends class _A ( metaclass=lowerCAmelCase ): snake_case__ : List[str] = ['onnx'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): ...
197
1
"""simple docstring""" from math import isqrt def lowerCAmelCase_( lowercase_ : int ) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(lowercase_ ) + 1 ) ) def lowerCAmelCase_( lowercase_ : int = 10**6 ) -...
73
"""simple docstring""" import qiskit def lowerCAmelCase_( lowercase_ : int , lowercase_ : int ) -> qiskit.result.counts.Counts: _lowerCamelCase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register ...
73
1
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _SCREAMING_SNAK...
85
'''simple docstring''' from __future__ import annotations import math class UpperCamelCase_ : def __init__( self , A ) -> None: UpperCAmelCase : Optional[int] = size # approximate the overall size of segment tree with given value UpperCAmelCase :...
265
0
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __UpperCAmelCase = HUGGINGFACE_HUB_CACHE __UpperCAmelCase = 'config.json' __UpperCAmelCase = 'diffusion_pytorch_model.bin' __UpperCAmelCase = ...
145
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap __UpperCAmelCase = 'Usage of script: script_name <size_of_canvas:int>' __UpperCAmelCase = [0] * 100 + [1] * 10 random.shuffle(choice) ...
145
1
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_av...
326
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenize...
326
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): def __init__( self : L...
313
"""simple docstring""" import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import ...
313
1
import math def __lowercase ( _A , _A ) -> int: SCREAMING_SNAKE_CASE : int = len(lowerCamelCase__ ) SCREAMING_SNAKE_CASE : List[Any] = int(math.floor(math.sqrt(lowerCamelCase__ ) ) ) SCREAMING_SNAKE_CASE : List[A...
245
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils impor...
144
0
'''simple docstring''' from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transfo...
359
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def a_ ( lowerCamelCase : Iterable[str] , lowerCamelCase : int ): lowerCAmelCase = iter(lowerCamelCase ) while True: lowerCAmelCase...
55
0
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelC...
73
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> float: if discount_rate < 0: raise ValueError('Discount rate cannot be negative' ) if not cash_flows: raise ValueError('Cash flows list cannot be empty' ) __lowerCamelCase : int = sum( cash_...
73
1
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_u...
358
'''simple docstring''' import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import com...
48
0
'''simple docstring''' from copy import deepcopy class A__ : """simple docstring""" def __init__( self : List[Any] , lowerCAmelCase__ : list[int] | None = None , lowerCAmelCase__ : int | None = None ) -> None: """simple docstr...
145
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __a = logging.get_logger(__name__) class A__ ( UpperCamelCase ): """simple docstring""" def __init__( self : Dict , *lo...
145
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowercase__ = TypeVar("T") lowercase__ = TypeVar("U") class snake_case__ ( Generic[T, U] ): """simple docstring""" ...
351
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixi...
83
0
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Random...
313
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('''ignore''', category=UserWarning, module='''torch.optim.lr_scheduler''') class a_ : """simple d...
313
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''BridgeTower/bridgetower-base''': '''https://huggingface.co/BridgeTower/...
125
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load...
125
1
def lowercase__ ( __snake_case : List[str] , __snake_case : str , __snake_case : int , __snake_case : Union[str, Any] , __snake_case : Tuple , __snake_case : str ): '''simple do...
29
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStr...
55
0
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCAmelCase = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCAmelCase = [ord(letter) for letter in string.asci...
370
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType UpperCAmelCa...
172
0
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_fnet import FNet...
348
def A ( _SCREAMING_SNAKE_CASE ) -> list: if n_term == "": return [] lowerCamelCase : list = [] for temp in range(int(_SCREAMING_SNAKE_CASE ) ): series.append(f'''1/{temp + 1}''' if series else "1" ) return s...
48
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=False)...
355
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu from ac...
33
0
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, ra...
21
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class lowercase__ : def __init__( self : List[Any] ,lowerCamelCase__ : int ,lowerCamelCase__ : MutableSequence[float] ): '''simple docstring''' if len(l...
83
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class A__ ( metaclass=UpperCamelCase ): """simple docstring""" UpperCamelCase_ : Tuple = ['''torch''', '''scipy'''] def __init__( self : List[str] , *lowerCAmelCase__...
357
'''simple docstring''' def __UpperCAmelCase ( a_: int, a_: int ): if not isinstance(a_, a_ ): raise ValueError("iterations must be defined as integers" ) if not isinstance(a_, a_ ) or not number >= 1: raise ValueError( "starting number must be\n ...
17
0
'''simple docstring''' import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py snake_case_ : Any = "src/transformers" # This is to make sure the tran...
125
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_a...
125
1
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( snake_case : int = 100_0000 )-> Optional[Any]: '''simple docstring''' UpperCAmelCase__ : Any = 1 UpperCAmelCase__ : Optional[int] = 1 UpperCAmelCase__ : List[Any] = {1: 1} ...
370
"""simple docstring""" import qiskit def SCREAMING_SNAKE_CASE__ ( snake_case : int , snake_case : int )-> qiskit.result.counts.Counts: '''simple docstring''' UpperCAmelCase__ : str = qiskit.Aer.get_backend("aer_simulator" ) UpperCAme...
298
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : Tuple = {"configuration_opt": ["OPT_PRETRAI...
347
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: '''simple docstring''' while a != 0: __snake_case , __snake_case : Optional[Any] = b % a, a return b def __UpperCAmelCase...
172
0
"""simple docstring""" from __future__ import annotations def _snake_case ( UpperCAmelCase_ : list[int] , UpperCAmelCase_ : list[int] , UpperCAmelCase_ : int ): A__ = list(range(len(lowerCAmelCase__ ) ) ) A_...
361
"""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 a ( _lowerCamelC...
69
0
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTe...
325
"""simple docstring""" def lowercase ( __snake_case : list[int] ): lowercase_ : List[Any] = len(__snake_case ) for i in range(__snake_case ): for j in range(i + 1 , __snake_case ): if numbers[j] < numbers[i]: lowercase_ , lower...
33
0
"""simple docstring""" from typing import Any class _a : def __init__( self : Any, lowerCAmelCase__ : Any ) -> Dict: '''simple docstring''' _UpperCamelCase : Optional[int] = data _...
128
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelin...
128
1
'''simple docstring''' from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor from .base import PipelineTool class _A ( __SCREAMING_SNAKE_CASE ): _SCREAMING_SNAKE_CASE : Tuple = "openai/whisper-base" _SCREAMING_SNAKE_CASE : Union[str, Any] = (...
254
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _lowerCAmelCase ( unittest.TestCase ,lowercase ): """simple docstring""" def _lowercase ( self : List[Any] ): __lowercase = ...
17
0
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from transfo...
360
a_ = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
50
0
def A_ ( _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: List[Any] = generate_pascal_triangle(_UpperCAmelCase ) for row_idx in range(_UpperCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ) ...
13
'''simple docstring''' import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow _lowerCAmelCase = [ os.path.join(os.path.dirname(__file__), dirname) for...
298
0
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_pr...
354
lowerCAmelCase_ = 256 # Modulus to hash a string lowerCAmelCase_ = 100_0003 def lowerCamelCase_ ( lowerCAmelCase: str , lowerCAmelCase: str )-> bool: _snake_case : Optional[int] = len(lowerCAmelCase ) _snake_case : int = ...
260
0
import re from filelock import FileLock try: import nltk __lowerCAmelCase : Dict =True except (ImportError, ModuleNotFoundError): __lowerCAmelCase : List[Any] =False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def _...
9
"""simple docstring""" import argparse __UpperCamelCase = '''docs/source/_static/js/custom.js''' def UpperCAmelCase ( UpperCAmelCase ) -> int: with open(UpperCAmelCase , encoding='utf-8' , newline='\n' ) as f: snake_case_ = f....
69
0
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class lowercase ( SCREAMING_SNAKE_CASE__ ): def __init__( self ,A__ ,A__ = None ,A__ = None ,A__ = F...
97
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, Dist...
97
1
from pathlib import Path import fire def _lowerCAmelCase (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase): UpperCamelCase_ = Path(_lowerCAmelCase) UpperCamelCase_ = Path(_lowerCAmelCase) dest_dir.mkdir(exist_ok=_lowerCAmelCase) for path ...
128
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCAmelCase : Tuple =2_9979_2458 # Symbols UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase : int =symbol...
128
1
import itertools import math def _UpperCamelCase ( snake_case__ ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all mu...
342
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import...
342
1
'''simple docstring''' def a_ ( __snake_case : list , __snake_case : list , __snake_case : int ) -> int: """simple docstring""" if len(__snake_case ) != len(__snake_case ): raise ValueError('''The length of ...
75
from __future__ import annotations def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase ) -> list[tuple[int, int]]: lowerCamelCase__ , lowerCamelCase__ : Union[str, Any] = position lowerCamelCase__ : Optional[Any] = [ (y + 1,...
50
0
from __future__ import annotations from dataclasses import dataclass @dataclass class _snake_case : _lowercase : float _lowercase : TreeNode | None = None _lowercase : TreeNode | None = None def lowerCamelCase__ (_Upp...
327
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, ...
327
1
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device __lowerCAmelCase : Optional[int] = False class snake_case__ (unitt...
107
"""simple docstring""" 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_see...
260
0
"""simple docstring""" # 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.configura...
233
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore __SCREAMING_SNAKE_CASE : List[str] = namedtuple('covid_data', 'cases deaths recovered') def _a ( _SCREAMING_SNAKE_CASE = "https://www.worldometers.info/coronavirus/" ) ...
233
1
'''simple docstring''' from collections import defaultdict class lowercase : """simple docstring""" def __init__( self , UpperCamelCase_ , UpperCamelCase_ ): '''simple docstring''' UpperCamelCase__ :List[Any] = total # total no of tasks (N) # DP table ...
97
'''simple docstring''' from datetime import datetime as dt import os from github import Github __snake_case = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def a ( ) -> List[s...
97
1
'''simple docstring''' __snake_case = 65521 def a ( __a ): '''simple docstring''' UpperCamelCase__ :Tuple = 1 UpperCamelCase__ :Tuple = 0 for plain_chr in plain_text: UpperCamelCase__ :int = (a + o...
361
'''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 # # Un...
219
0
import itertools import math 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 even numbers, all mul...
342
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils i...
342
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase__ : str = { '''configuration_resnet''': ['''RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP...
155
"""simple docstring""" def __lowercase ( _a ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
155
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available _SCREAMING_SNAKE_CASE = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDependencyN...
327
from collections import namedtuple import requests from lxml import html # type: ignore _SCREAMING_SNAKE_CASE = namedtuple("""covid_data""", """cases deaths recovered""") def SCREAMING_SNAKE_CASE__ ( __a = "https://www.worldometers.info/coronavirus/" ): snake_case_ ...
327
1
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : Union[str, Any] ): __UpperCamelCase =1 __UpperCamelCase =2 while i * i <= n: __UpperCamelCase =0 while n % i == 0: n //= i multiplicity += 1 n_div...
117
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 _UpperCAmelCase ( SCREAMING_SNAKE_CA...
117
1