code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import re import subprocess import sys __magic_name__ : int = subprocess.check_output('''git merge-base main HEAD'''.split()).decode('''utf-8''') __magic_name__ : Any = subprocess.check_output(F'git diff --name-only {fork_point_sha}'.split()).decode('''utf-8''').spl...
280
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import requ...
224
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) snake_case_ : List[str] = { """configuration_trocr""": ["""TROCR_PRETRAIN...
292
"""simple docstring""" def lowercase_ ( _lowercase : list , _lowercase : int , _lowercase : int = 0 , _lowercase : int = 0 ): '''simple docstring''' UpperCAmelCase : Tuple = right or len(_lowercase ) - 1 if le...
292
1
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoPro...
5
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_ava...
512
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.se...
703
'''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 # ...
691
0
'''simple docstring''' from __future__ import annotations class _UpperCAmelCase : """simple docstring""" def __init__( self : Dict , __UpperCAmelCase : list[list[int]] ): '''simple docstring''' _A = TypeError( "M...
330
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) lowerCamelCase_ = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block'''...
330
1
'''simple docstring''' import pprint import requests __UpperCamelCase : List[str] = "https://zenquotes.io/api" def __UpperCAmelCase ( ) -> Tuple: """simple docstring""" return requests.get(API_ENDPOINT_URL + '/today' ).json() def __UpperCAmelCase ( ) -...
705
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Tuple = { """configuration_blip_2""": [ """BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
270
0
from __future__ import annotations import math class _UpperCamelCase : '''simple docstring''' def __init__( self : Dict , a : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : Dict = size # approximate the overall size of s...
25
# 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 by ap...
68
0
"""simple docstring""" # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def UpperCamelCase ( _A , _A , _A , _A ) -> Optional[int]: lowercase : List[Any] = { """en""": """Machine learning is great, isn't ...
348
"""simple docstring""" import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap...
348
1
from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( IMAGENET_STANDARD_MEA...
243
import itertools import math def lowerCAmelCase__( lowercase : int ) -> 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 multiples of 3 are not primes re...
243
1
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_lo...
509
"""simple docstring""" def A_ ( UpperCAmelCase__ , UpperCAmelCase__ ) -> float: if discount_rate < 0: raise ValueError('Discount rate cannot be negative' ) if not cash_flows: raise ValueError('Cash flows list cannot be empty' ) a : List[str...
509
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : Optional[int] = logging.get_logger(__name__) _UpperCamelCase : List[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/mark...
284
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy a...
284
1
"""simple docstring""" def snake_case ( UpperCamelCase__ : int , UpperCamelCase__ : int ) -> int: return int((input_a, input_a).count(0 ) != 0 ) def snake_case ( ) -> None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0...
42
"""simple docstring""" import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from...
42
1
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> np.ndarray: """simple docstring""" A__ = ...
87
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int = 100_0000 ) -> int: _UpperCAmelCase : str = set(range(3 , lowerCAmelCase , 2 ) ) primes.add(2 ) for p in range(3 , lowerCAmelCase , 2 ): if p not in primes: continue primes.diffe...
300
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : str = 100_0000 ) ->Optional[int]: '''simple docstring''' a : Optional[int] = limit + 1 a : Dict = [0] * limit for first_term in range(1 , _lowercase ): f...
708
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __UpperCamelCase ( unittest.TestCase ): def __a ( self ) -> Optional[Any]: a : Optional[int] = [ ...
31
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 ( ChannelDim...
195
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case_ : Union[str, An...
195
1
from random import randint, random def UpperCamelCase_ ( __a , __a , __a , __a = False , __a = False , __a = 5 , ) -> list: a__ : Optional[Any] = [[-1] * number_of_cells] # Create a highway without any car a__ : List[Any...
702
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects...
151
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowercase_ = logging.get_logger(__name__) def lowerCAmelCase (__A): """simple docstring""" ...
11
"""simple docstring""" def lowerCAmelCase_ (_SCREAMING_SNAKE_CASE :str ) -> int: assert column_title.isupper() a_ : int = 0 a_ : Tuple = len(_SCREAMING_SNAKE_CASE ) - 1 a_ : Union[str, Any] = 0 while index >= 0: ...
473
0
'''simple docstring''' import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin _UpperCamelC...
721
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
211
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def a__ ( snake_case , snake_case ): """simple docstring""" return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(snake_case , snake_case ) ) ...
74
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, ...
544
0
def snake_case_ (__A : int = 6_0_0_8_5_1_4_7_5_1_4_3 ) -> int: try: __lowerCAmelCase : Dict = int(__A ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: raise ValueError("""Parameter n ...
218
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring...
218
1
'''simple docstring''' import math class _UpperCamelCase : '''simple docstring''' def __init__( self : int , lowerCAmelCase__ : Dict=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[int] = ...
578
"""simple docstring""" import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
673
0
from math import factorial class SCREAMING_SNAKE_CASE__ : def __init__( self : Optional[Any] , _lowerCAmelCase : Any , _lowerCAmelCase : List[str] ): __snake_case : Optional[int] = real if isinstance(_lowerCAmelCase , _lowerCAme...
713
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from .....
390
0
import numpy as np UpperCamelCase = [ ["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 lowerCAmelCase_ : def __init__( self ): _lowercase : Any ...
66
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def __magic_name__ ( SCREAMING_SNAKE_CASE ) -> List[An...
66
1
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
103
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, req...
103
1
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __lowercase ( A ): __magic_name__ : Union[str, Any] = (IPNDMScheduler,) __magic_name__ : Optional[Any] = ((...
141
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, requ...
141
1
import argparse from collections import defaultdict def lowercase ( _a ,_a ,_a ,_a ,_a ) -> Union[str, Any]: UpperCAmelCase_: Any = f"{file}_{class_name}_{test_name}" done_test[_id] += 1 with open(_a ,"r" ) as f: UpperCAmelCase_: Union[s...
709
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import...
306
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCamelCase__ : Dict = logging.get_logger(__n...
33
"""simple docstring""" SCREAMING_SNAKE_CASE__ : Optional[Any] ={ 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'AB...
434
0
from typing import Any class _UpperCamelCase : def __init__( self: Any , _SCREAMING_SNAKE_CASE: Tuple ) -> List[str]: """simple docstring""" UpperCamelCase_ = data UpperCamelCase_ = None def __repr__(...
713
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.hugging...
371
0
'''simple docstring''' from maths.prime_factors import prime_factors def UpperCamelCase__ ( _lowercase : int ) -> int: if not isinstance(_lowercase , _lowercase ): __UpperCAmelCase: List[str] = F'''Input value of [number={number}] must be an integer''' ...
523
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def UpperCamelCase__ ( _lowercase : Dict ) -> str: for param in module.parameters(): __UpperCAmelCase: int = False def UpperCamelCase__ ( ) ...
523
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, Stabl...
558
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging ...
558
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _UpperCamelCase = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_torch_available(): ...
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/licenses...
516
0
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 TokenizerTesterMixin class a_ ( lowerCame...
701
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": _lowerCamelCase =argparse.ArgumentParser( description=( "Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer Learned" " Distillation...
252
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow lowerCamelCase : int = False class A( unittest.TestCase ): ...
70
"""simple docstring""" import os import pytest from attr import dataclass SCREAMING_SNAKE_CASE__:List[str] = """us-east-1""" # defaults region @dataclass class snake_case__ : _snake_case : str _snake_case : Optional[Any] = """arn:aws:iam::558105141721:role...
528
0
from __future__ import annotations from math import pi, sqrt def _lowerCamelCase ( __A : float , __A : float ) -> tuple: if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: raise...
186
import math def _lowerCamelCase ( __A : int ) -> int: if not isinstance(__A , __A ): _UpperCAmelCase : List[Any] = f'''Input value of [number={number}] must be an integer''' raise TypeError(__A ) if number < 1: _Upper...
186
1
'''simple docstring''' import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __A = { "iou_p...
325
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCAmelCase = {"""configuration_unispeech""": ["""UNISPEECH_PRETRAINED_CONFIG_ARCHIVE...
409
0
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig 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_ba...
707
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets __A = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into acco...
173
0
"""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 imp...
645
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, ...
645
1
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline ...
709
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.tes...
167
0
import argparse 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_dummies.py a__ = '''src/diffusers''' # Matches is_xxx_available() a__ = re.compile(R'''is\_([a-z_]*)_availab...
14
'''simple docstring''' from __future__ import annotations from random import choice def a_ ( lowerCamelCase : Optional[Any] ): return choice(lowerCamelCase ) def a_ ( lowerCamelCase : list[int] , lowerCamelCase : int...
133
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __magic_name__ : __A : int __A : TreeNode | None = None __A : TreeNode | None = None UpperCAm...
711
"""simple docstring""" from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase () -> tuple[list[int], int]: lowercase :Any = [randint(-1000 , 1000) for i in range(10)] ...
475
0
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def lowerCamelCase__ ...
73
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A : Union[str, Any] = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvN...
15
0
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutpu...
440
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class lowercase__ ( ...
440
1
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def SCREAMING_SNAKE_CASE ( *lowerCAmelCase__ : str , lowerCAmelCase__ : Optional[Union[Dict, Any]] = None , lowerCAmelCase__ : List[str...
125
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae impor...
125
1
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCAmelCase_ ( nn.Module ): """simple docstring""" _lowerCAmelCase :...
708
"""simple docstring""" def lowerCAmelCase__ ( _UpperCamelCase : int , _UpperCamelCase : int ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def lowerCAmelCase__ ( ) -> None: ...
104
0
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( _UpperCAmelCase : list , _UpperCAmelCase : int | None = None , _UpperCAmelCase : int | None = None ) -> List[str]: """simple docstring""" if start is None: ...
244
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, D...
478
0
"""simple docstring""" import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_...
713
"""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 ...
215
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 convert Vicuna checkpoints, we...
588
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : int ): lowercase = abs(lowercase_ ) lowercase = 0 while n > 0: res += n % 10 n //= 10 return res def SCREAMING_SNAKE_CASE ( lowercase_ : int ): ...
588
1
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class S...
62
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { 'roberta-base': 'https://huggingface.co/roberta-base/resolve/main/confi...
62
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
556
import numpy as np def lowerCAmelCase_ (lowerCAmelCase__: np.ndarray , lowerCAmelCase__: float ): """simple docstring""" return np.where(vector > 0 , lowerCAmelCase__ , (alpha * (np.exp(lowerCAmelCase__ ) - 1)) ) if __name__ == "__main__": impo...
556
1
snake_case = """Alexander Joslin""" import operator as op from .stack import Stack def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Any = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} SCREAMING_SNAKE_CASE :...
716
# 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 by ap...
488
0
class __snake_case : '''simple docstring''' def __init__( self , A_ , A_ , A_ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = name SCREAMING_SNAKE_CASE__ = value SCREAMING_SNAKE_CASE__ = wei...
100
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
100
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer __A : List[Any] = logging.get_logge...
716
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class __lowerCAmelCase ( nn.Module): '''simple docstring''' def __init__( self : Union[str, Any] , UpperCamelCase__ ...
595
0
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCamelCase ( unittest.TestCase ): """si...
534
def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" __lowercase = word.split() def justify(lowercase , lowercase , lowercase ) -> str: __lowercase = max_width - width __lowercase = len(lo...
534
1
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_in...
327
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { '''snap-research/efficientformer-l1-300''': ( '''https://huggingface.co/snap...
327
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _a : Union[str, Any] = logging.get_logger(__name__) class _lowercase ( __SCREAMING_SNAKE_CASE ): def __init__( self : Optional[Any] ...
56
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices A_ : int = logging.get_logger(__name__) A_ : Dict = { "google/bit-50": "https:/...
38
0
import math from datetime import datetime, timedelta def _lowercase ( UpperCamelCase_ ) -> datetime: '''simple docstring''' SCREAMING_SNAKE_CASE__ = year % 19 SCREAMING_SNAKE_CASE__ = year % 4 SCREAMING_SNAKE_CASE__ = year % 7 SCREAMING_SN...
400
import math from datetime import datetime, timedelta def _lowercase ( UpperCamelCase_ ) -> datetime: '''simple docstring''' SCREAMING_SNAKE_CASE__ = year % 19 SCREAMING_SNAKE_CASE__ = year % 4 SCREAMING_SNAKE_CASE__ = year % 7 SCREAMING_SN...
400
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class __UpperCamelCase ( lowerCAmelCase__ ): """simple docstring""" ...
74
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast lowercase_ = datasets.utils.logging.get_logger(__name__) @dataclass class __UpperCamelCase ( datasets.Bui...
74
1
"""simple docstring""" 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 fro...
215
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase ): """simple docstring""" def get_matched_characters(__UpperCamelCase , __UpperCamelCase ) -> str: __A = [] __A = min(len(_stra ) , len(_stra ) ) // 2 for i,...
215
1
'''simple docstring''' from __future__ import annotations def lowercase_ ( __A : list[int] ) -> list[int]: # This function is recursive """simple docstring""" lowercase : str =len(__A ) # If the array contains only one element, we return it (it's t...
94
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase_ ( __A : str ) -> Union[str, Any]: """simple docstring""" return x + 2 class UpperCAmelCase_ ...
94
1
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 impo...
706
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_uti...
69
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
385
"""simple docstring""" from math import sqrt def __lowercase ( _a ): assert isinstance(_a , _a ) and ( number >= 0 ), "'number' must been an int and positive" snake_case_ : List[str] = True # 0 and 1 are none primes. if number <= 1: ...
123
0
from __future__ import annotations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ): '''simple docstring''' if len(SCREAMING_SNAKE_CASE__ ) <= 1 or n <= 1: return insert_next(SCREAMING_SNAKE_CASE__ ,n - 1 ...
693
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase : int ={ 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', ...
693
1
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from d...
479
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : List[str] = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], 'configuration_data2vec_t...
479
1
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) ...
702
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _SCREAMING_SNAKE_CASE ( snake_case_ : Optional[Any] ): __magic_name__ = SwinConfig(image_size=192 ) if "base" in model_name: ...
678
0
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """kakaobrain/align-base""": """https://hug...
411
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """tiiuae/falcon-40b""": """https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json""", """tiiuae/falcon-7b""": """https://huggin...
411
1
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) UpperCamelCase_ = { "sample_size": 3_2, "in_channels": 3, "out_channels": 3, "layer...
508
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfi...
508
1
'''simple docstring''' 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, g...
526
'''simple docstring''' from __future__ import annotations lowerCAmelCase: str = 'Muhammad Umer Farooq' lowerCAmelCase: List[str] = 'MIT' lowerCAmelCase: Tuple = '1.0.0' lowerCAmelCase: List[Any] = 'Muhammad Umer Farooq' lowerCAmelCase: Optional[Any] = 'contact@muhammadumerf...
526
1
import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def A_ ( __a : Optional[Any] , __a : Any , __a : Dict ): """simple docstring"...
351
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transfo...
351
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ : Optional[int] = { "configuration_conditional_detr": [ "CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP"...
120
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCAmelCase = { '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''LongT5OnnxConfig'''], }...
677
0
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(__lowerCamelCase ...
461
'''simple docstring''' def __a ( __lowerCamelCase : int = 600_851_475_143 ) -> int: '''simple docstring''' try: lowercase_ = int(__lowerCamelCase ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) ...
461
1
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataL...
141
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCamelCase_ ( __UpperCamelCase = "" ): A_ = url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250''' A_ = BeautifulSoup(requests.get(__UpperCamelCase ).text ...
141
1
# 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 b...
721
import requests from bsa import BeautifulSoup def lowerCamelCase_ ( UpperCamelCase_ = "AAPL" ): _a : List[str] = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" _a : Any = BeautifulSoup(requests.get(UpperCamelCase_ ).text , '''html.parser''' ...
249
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase__ : Optional[int] = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMCon...
8
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeat...
363
0
# Copyright 2021 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 b...
421
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_modules import _PACKAGED_DATAS...
421
1
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class lowercase ( enum.E...
304
# Lint as: python3 import itertools import os import re lowercase_ : List[Any] = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowercase_ : Tuple = re.compile(r'''([a-z\d])([A-Z])''') lowercase_ : Dict = re.compile(r'''(?<!_)_(?!_)''') lowercas...
304
1
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf a_ : Union...
707
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : List[str] = logging.get_logger(__name__) a_ : Dict = { """microsoft/unispeech-large-1500h-cv""": ( ...
445
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Any = {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFI...
87
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 ...test_modeli...
544
0
_A = range(2, 20 + 1) _A = [10**k for k in range(ks[-1] + 1)] _A = {} def __SCREAMING_SNAKE_CASE ( UpperCamelCase : Optional[Any] , UpperCamelCase : Tuple , UpperCamelCase : List[str] , UpperCamelCase : str ) -> str: """s...
716
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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(): import jax...
403
0
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_lo...
11
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_commo...
11
1
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : int ): """simple docstring""" __snake_case = n __snake_case = [None] * self.n __snake_case = 0 # index of the first element ...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = {"""configuration_mmbt""": ["""MMBTConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNo...
569
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch _lowerCAmelCase = """sshleifer/bart-tiny-random""" _lowerCA...
569
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase : str = {"configuration_xlnet"...
674
"""simple docstring""" import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def _UpperCAmelCase ( lowerCamelCase__ , lowerCam...
674
1
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping A_ = tuple[int, int] class __lowerCAmelCase : '''simple docstring''' def __init__( self: Optional[Any] , UpperCamelCase_: List[Any] , UpperCamelCase_: ...
391
"""simple docstring""" import random def _snake_case ( __snake_case : List[Any] , __snake_case : List[Any] , __snake_case : int ): """simple docstring""" _lowerCamelCase : List[str] = a[left_index] _lowerCamelCase...
88
0
"""simple docstring""" from collections.abc import Generator def __UpperCAmelCase ( ) -> Generator[int, None, None]: lowercase__ , lowercase__ : int = 0, 1 while True: lowercase__ , lowercase__ : int = b, a + b yield b de...
122
"""simple docstring""" from ..utils import DummyObject, requires_backends class __A ( metaclass=A_ ): '''simple docstring''' lowerCAmelCase : Optional[Any] = ["flax", "transformers"] def __init__( self : Union[str...
122
1
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __a (...
554
"""simple docstring""" SCREAMING_SNAKE_CASE = {} def lowerCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ )-> int: """simple docstring""" # if we are absent twice, or late 3 consecutive days, # no further prize strin...
554
1
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...
202
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __A(lowerCAmelCase ) -> List[str]: """simple docstring""" if "model" in orig_key: _UpperCamelCase = orig_key.replace("""model.""" , """""" ) if "norm1" in orig_key: _UpperCamelCase ...
202
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SC...
465
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Union[str, Any] = {"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]} try: if no...
564
0
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar A_ = TypeVar("T") def __UpperCAmelCase ( UpperCAmelCase )-> List[Any]: """simple docstring""" return (position - 1) // 2 def ...
714
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def __UpperCAmelCase ( UpperCAmelCase )-> bool: """simple docstring""" lowercase = int(number**0.5 ) return number == sq * sq ...
479
0
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase__ ...
612
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_dimension_format, ) from ...
612
1
"""simple docstring""" import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case_ : List[str] = ( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH ...
708
"""simple docstring""" def lowercase_ ( _lowercase : str ): '''simple docstring''' if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) UpperCAmelCase : Optional[int] = sorted(string.lower() ) ...
292
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class lowerCamelCase_ : def __init__( self , __lowerCAmelCase = None ): """simple docstring""" if components is None: __m...
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase_ ( lowerCamelCase ): a__ = ['''image_processor''', '''tokenizer'''] a__ = '''ChineseCLIPImageProcessor''' a__ = ...
0
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : str = logging.get_logger(__name__) lowercase : List[Any] = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json''', '...
710
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowercase : List[str] = argparse.ArgumentParser() parser.add_argument('--dump_path', default=Non...
94
0
from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( __A : int ) -> bool: """simple docstring""" a_ : Union[str, Any] = str(__A ) return len(__A ) == 9 and set(__A ) == set('123456789' ) ...
570
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=lowercase__ ): snake_case__ : List[str] = ['''onnx'''] def __init__( self : List[Any] , *SCREAMING_SNAKE_CASE__ : Dict , **SCREAMING_SNAKE_CASE__ : ...
570
1
"""simple docstring""" import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from...
715
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig fro...
696
0
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_configuration_common imp...
623
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, ...
623
1
"""simple docstring""" import logging from transformers import PretrainedConfig __lowerCAmelCase : List[str] = logging.getLogger(__name__) __lowerCAmelCase : Optional[Any] = { "bertabs-finetuned-cnndm": "https://huggingface.co/remi/bertabs-finetuned-cnndm...
719
"""simple docstring""" import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class a_ : def __init__( self : Optional[int] , snake_case__ : List[Any]=2 , snake_case__ : Any=3 , ...
674
0
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_v...
283
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json""", # See all Donut ...
678
0
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class UpperCAmelCase_ (nn.Module ): """simple docstring""" lowerCamelCase : int lowerCamelCase : int...
382
# 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 by...
382
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( ): """simple docstring""" a_ : Union[str, Any] = [] a_ : Optional[Any] = 1 while len(UpperCamelCase__ ) < 1E6: constant.append(str(UpperCamelCase__ ...
442
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class SCREAMING_SNAKE_CASE ( tf.k...
442
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, slo...
718
_A : Tuple = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def __lowerCAmelCase ( ) -> None: __lowerCamelCase: Optional[int] = input("""Enter message: """ ) __lowerCamelCase: Dict = input("""Enter key [alphanumeric]: """ ) __lowerCamelCase: List[Any] =...
189
0