code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional impo...
216
def __UpperCamelCase ( lowerCAmelCase__ : int = 5_0_0_0_0_0_0_0 ): __a : int = set() __a : str = int((limit - 2_4) ** (1 / 2) ) __a : int = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ): if p...
216
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _snake_case : Union[str, Any] = logging.get_logger(__name__) class A ( _a ): def __init__( self : Dict , ...
179
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _snake_case : int = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig...
179
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[str] ...
105
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : float , _lowercase : float ) ->float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(100, 0.25) = }''') ...
105
1
"""simple docstring""" import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Config...
128
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling...
128
1
"""simple docstring""" def _snake_case ( lowercase__ , lowercase__ ): return int((input_a, input_a).count(0 ) == 0 ) def _snake_case ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gat...
96
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) # TODO Update this UpperCAmelCase__ = { '''facebook/esm-1b''': '''https://huggingface.co/fac...
5
0
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTes...
208
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCamelCase : Any = r"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the m...
208
1
"""simple docstring""" import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import requir...
77
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAvail...
326
0
"""simple docstring""" def a__ ( lowerCAmelCase , lowerCAmelCase ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCAmelCase__ : Optional[Any] = str(bin(lowerCAmelCase ) )[2:] # remove the leading "0b" Up...
166
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from t...
166
1
from __future__ import annotations from fractions import Fraction def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def __snake_case ( _UpperCAmelCase ): __a ...
49
"""simple docstring""" from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
45
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase :Any = logging.get_logger(__name__) _lowerCAmelCase :int = { 'facebook/xlm-roberta-xl...
360
"""simple docstring""" from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase_ (): _UpperCAmelCase : Optional[int] = [randint(-1000 , 1000 ) for i in range(10 )] _UpperCAme...
68
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
222
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py lowercase : List[str] = """src/transformers""" lowercase : ...
99
0
from math import pow def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , ): if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_c...
356
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_ava...
256
0
"""simple docstring""" from manim import * class snake_case__ ( snake_case_ ): def a__ ( self ): __a = Rectangle(height=0.5 , width=0.5 ) __a = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) __a = Rectangle(heigh...
261
"""simple docstring""" import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_co...
261
1
from __future__ import annotations from PIL import Image # Define glider example _snake_case = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, ...
366
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case = { """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AutoformerConfig""", ...
201
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow fr...
95
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 _snake_case = logging.get_logger(__name__) _snake_case = { ...
283
0
'''simple docstring''' import math def lowerCamelCase__ ( _A ): if not isinstance(_A , _A ): a : Union[str, Any] = f"""Input value of [number={number}] must be an integer""" raise TypeError(_A ) if number < 1: a : Dict = f"""In...
351
'''simple docstring''' from math import factorial, pi def lowerCamelCase__ ( _A , _A = 30 ): if not isinstance(_A , (int, float) ): raise ValueError('maclaurin_sin() requires either an int or float for theta' ) if not isinstance(_A , _A ) or accuracy <= 0: ...
96
0
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import logging l...
248
_lowerCamelCase ={ "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_0.0_0...
287
0
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": lowerCamelCase : Optional[Any] =pd.read_csv('''sample_data.csv''', header=No...
355
from ..utils import DummyObject, requires_backends class __a ( metaclass=A__ ): _lowerCAmelCase : str = ['''torch'''] def __init__( self : int , *SCREAMING_SNAKE_CASE : Optional[Any] , **SCREAMING_SNAKE_CASE : List[str] ...
196
0
"""simple docstring""" 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, EulerAncestralDiscreteScheduler, LM...
191
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistep...
71
0
import random from typing import Any def _snake_case( SCREAMING_SNAKE_CASE__ : list ) -> list[Any]: '''simple docstring''' for _ in range(len(SCREAMING_SNAKE_CASE__ ) ): A__ = random.randint(0 , len(SCREAMING_SNAKE_CASE...
282
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass lowercase_ = (3, 9, -11, 0, 7, 5, 1, -1) lowercase_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class A : """simple docstring""" lowerCamelCas...
282
1
"""simple docstring""" def lowercase (SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : int ) -> float: if digit_amount > 0: return round(number - int(_lowerCAmelCase ) , _lowerCAmelCase ) return number - int(_lowerCAmelCase ) if __name__...
113
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
0
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, OPENA...
357
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 as jnp from flax.jax_u...
200
0
'''simple docstring''' from __future__ import annotations __a = 1.6021E-19 # units = C def __snake_case( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , ) -> tuple[str, float]: if (conductivity, electron_conc, mobility).count(0 ) != 1: raise...
35
'''simple docstring''' import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
145
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. snake_case_ : Any = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that ge...
236
'''simple docstring''' from __future__ import annotations import numpy as np def A__ ( UpperCAmelCase_ ): _UpperCamelCase , _UpperCamelCase : Optional[int] = np.shape(UpperCAmelCase_ ) if rows != columns: _UpperCamelCase : Union[str, Any] ...
236
1
'''simple docstring''' from random import shuffle import tensorflow as tf from numpy import array def _A ( A__ , A__ ): """simple docstring""" __lowercase = int(A__ ) assert noofclusters < len(A__ ) # Find out the dimensionality __lowercase = len(...
104
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''KT''') lowerCAmelCase__ = TypeVar('''VT''') class lowercase_ (Generic[KT, VT] ): """simple docstring""" def __init...
104
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 transf...
240
'''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_bert import BertTokenizer __UpperCAmelCase :Dict = log...
240
1
import socket def a_ ( ): '''simple docstring''' _lowerCamelCase : Optional[Any] =socket.socket(socket.AF_INET , socket.SOCK_STREAM ) _lowerCamelCase : Union[str, Any] =socket.gethostname() _lowerCamelCase : int =12_312 sock.connect...
199
import os import pytest from attr import dataclass lowerCamelCase = 'us-east-1' # defaults region @dataclass class A : UpperCamelCase__ : str UpperCamelCase__ : Dict ='arn:aws:iam::558105141721:role/sagemaker_execution_role' UpperCamelCase__ : int ...
199
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : Dict = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', ...
368
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case__ : Tuple = { 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_C...
250
0
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mod...
279
from math import factorial lowerCAmelCase_ = {str(digit): factorial(digit) for digit in range(1_0)} def lowerCamelCase_ ( _UpperCamelCase ) -> int: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('''Parameter ...
279
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase : Dict = {"configuration_xlnet": ["XLNET_PRETRAI...
208
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) lowerCamelCase : str = {name: get...
208
1
"""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 ModelMixi...
292
"""simple docstring""" import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class _UpperCAmelCase : UpperCamelCase = None def lowerCamelCase ( self :List[Any] ): A = self.feature_extraction_...
292
1
"""simple docstring""" import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a = logging.get_logger(__name__) a = { '''vocab_file''': '''vocab.txt''', '''merg...
356
"""simple docstring""" from __future__ import annotations import time import numpy as np a = [8, 5, 9, 7] a = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a = [ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, ...
271
0
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _lowerCAmelCase ( ) -> Any: """simple docstring""" _SCREAMING_SNAKE_CASE =9 _SCREAMING_SNAKE_CASE =[ [0, 1, 4], [0, 7, 8], [1, 2, 8], ...
47
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCAmelCase__ = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and...
339
0
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline __snake_case = logging.get_logger(__name__) class ...
362
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 10_00 ): """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3, n + 1 ) ) if __name__ == "__main__": print(solution())
153
0
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_available, is_vision_avai...
212
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> np.array: lowerCAmelCase__ : Dict = F'''{sampling_rate}''' lowerCAmelCase__...
212
1
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def a__ ( A__ ): SCREAMING_SNAKE_CASE_ : Union[str, Any] = [ 'encoder.version', 'decoder.version', 'model.encoder.ve...
162
import numpy # List of input, output pairs lowerCAmelCase__ : int =( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) lowerCAmelCase__ : Any =(((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) lowerCAmelCase__ : Lis...
162
1
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __snake_case ( __A ,__A ): __lowerCamelCase = 1 ...
143
def lowerCamelCase__ ( _a , _a): return int((input_a, input_a).count(1) != 0) def lowerCamelCase__ ( ): assert or_gate(0 , 0) == 0 assert or_gate(0 , 1) == 1 assert or_gate(1 , 0) == 1 assert or_gate(1 , 1) == 1 if __name__ == "__main__": print(...
76
0
from math import factorial def a_ ( lowerCAmelCase_ : int, lowerCAmelCase_ : int, lowerCAmelCase_ : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or successes < 0: raise ValueError('the...
350
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...
207
0
"""simple docstring""" from __future__ import annotations import pandas as pd def _lowerCAmelCase ( lowercase_ , lowercase_ , lowercase_ ): UpperCAmelCase = [0] * no_of_processes UpperCAmelCase = [0] * no_of_processes # Copy the burst time i...
78
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_utils import en...
21
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import...
134
import logging from transformers.configuration_utils import PretrainedConfig _snake_case : Optional[Any] = logging.getLogger(__name__) class a (_lowerCAmelCase ): """simple docstring""" __UpperCAmelCase : Tuple = "masked_bert" def __init__( se...
134
1
"""simple docstring""" import numpy as np def snake_case ( A__ ,A__ ,A__ = 1e-12 ,A__ = 1_00 ,): assert np.shape(A__ )[0] == np.shape(A__ )[1] # Ensure proper dimensionality. assert np.shape(A__ )[0] == np.shape(A__ )[0] # Ensure inputs are either both complex or both ...
268
"""simple docstring""" # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import V...
268
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch ...
26
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class lowercase_ ( lowercase ): '''simp...
26
1
def lowerCAmelCase_ ( __A, __A ) -> int: '''simple docstring''' while b: UpperCAmelCase__ , UpperCAmelCase__ = b, a % b return a def lowerCAmelCase_ ( __A, __A ) -> int: '''simple do...
65
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class __UpperCamelCase : def __init__( self ): """simple docstring""" lowerCamelCase_ ='''''' lowerCamelCase_ ...
75
0
"""simple docstring""" def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ) -> Any: if index == r: for j in range(lowerCAmelCase ): print(data[j] , end=""" """ ) print(""" ...
166
"""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 ( lower...
166
1
'''simple docstring''' from __future__ import annotations __SCREAMING_SNAKE_CASE : Optional[int] = list[list[int]] # assigning initial values to the grid __SCREAMING_SNAKE_CASE : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3,...
31
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable __SCREAMING_SNAKE_CASE : Optional[int] = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCH...
31
1
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor...
369
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __lowerCAmelCase ( U...
148
0
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_avail...
29
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home _UpperCAmelCase : Optional[int] = HUGGINGFACE_HUB_CACHE _UpperCAmelCase : List[str] = "config.json" _UpperCAmelCase : Union[str, Any] = "diffusion_pytorch_model.bin" _UpperCAmelCase ...
222
0
'''simple docstring''' class lowerCamelCase : '''simple docstring''' def __init__( self : Tuple , lowerCAmelCase_ : int ) -> Any: '''simple docstring''' A__ : Optional[int] =size A__ : Tuple =[0] * size ...
358
'''simple docstring''' def __lowerCamelCase ( __snake_case : int ) -> bool: """simple docstring""" if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True A__ : Any =4 A__ : ...
136
0
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization imp...
185
'''simple docstring''' 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, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
185
1
def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' return "".join(chr(ord(a__ ) - 32 ) if "a" <= char <= "z" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
63
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class _UpperCAmelCase ( Tenso...
63
1
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, val...
52
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Any = { """configuration_electra""": ["""ELECTRA_PRETRAINED_CONF...
52
1
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class lowercase_ ( pl.LightningModule ): def __init__( self : List[str] , A__ : Union[str, Any] ) -> Any: ...
278
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def snake_case_(_UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> Optional[Any]: """simple docstring""" _s...
278
1
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler,...
107
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path A : Optional[Any] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import iter...
6
0
'''simple docstring''' snake_case__ = { """Pillow""": """Pillow<10.0.0""", """accelerate""": """accelerate>=0.20.3""", """av""": """av==9.2.0""", """beautifulsoup4""": """beautifulsoup4""", """black""": """black~=23.1""", """codecarbon""": """codecarbon==1.2.0""", """...
356
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example snake_case__ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0...
4
0
"""simple docstring""" import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...te...
320
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCAmelCase__ ( __lowercase ): def __init__( self : Tuple , SCREA...
270
0
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time __A = Lock() def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNA...
254
"""simple docstring""" from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __A (_SCREAMING_SNAKE_CASE = "" ) ->dict[str, float]: """simple docstring""" lowerCAmelCase__ :Optional[Any] = url or 'https://www.imdb.com/ch...
254
1
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import Token...
196
_lowerCamelCase : int = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _lowerCamelCase : str = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _lowerCamelCase : List[str] = { 0: '''Sunday''', 1: '''Monday''', 2: '''Tuesday''', 3: '''Wednesday''', 4: '''Thursday''', ...
282
0
"""simple docstring""" 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_fu...
368
"""simple docstring""" from collections.abc import Callable import numpy as np def A_ ( _lowerCAmelCase : Callable, _lowerCAmelCase : float, _lowerCAmelCase : float, _lowerCAmelCase : float, _lowerCAmelCase : float ): """simp...
153
0
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config ...
3
import heapq import sys import numpy as np snake_case__ : Tuple = tuple[int, int] class A_ : def __init__(self :Union[str, Any] )-> Union[str, Any]: __A = [] __A = set() def _lowerCAmelCas...
117
0
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class...
359
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, **lowerCamelCase ): lowercase :List[Any] = AutoConfig.from_pretrained(lowerCamelCase, **lowerCamelCase ) lowercase :Union[st...
158
0
import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...t...
52
def A_ ( _lowerCAmelCase ) -> str: UpperCamelCase : List[Any] = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def A_ ( _lowerCAmelCase ) -> dict[str, str]: UpperCamelCase : Optional[An...
52
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : int ...
313
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD ...
313
1
"""simple docstring""" from __future__ import annotations def _A ( UpperCamelCase_ : list[int | str]) -> None: '''simple docstring''' create_state_space_tree(UpperCamelCase_, [], 0, [0 for i in range(len(UpperCamelCase_))]) def _A ( UpperCamelCase_ : list[in...
17
"""simple docstring""" import torch from transformers import AutoModel class SCREAMING_SNAKE_CASE ( torch.nn.Module ): """simple docstring""" def __init__( self : Tuple ,lowercase_ : Dict="sayef/fsner-bert-base-uncased" ): super(lowercase_ ,sel...
106
0
"""simple docstring""" def __a ( ) ->Tuple: a__: str = [] a__: Any = 1 while len(_SCREAMING_SNAKE_CASE ) < 1e6: constant.append(str(_SCREAMING_SNAKE_CASE ) ) i += 1 a__: int = ''.join(_SCREAMING_SNAKE_C...
356
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_model...
203
0
"""simple docstring""" from PIL import Image def a__ ( snake_case__ , snake_case__ ) -> Image: lowerCamelCase = (2_59 * (level + 2_55)) / (2_55 * (2_59 - level)) def contrast(snake_case__ ) -> int: return int(1_28 + factor * (c - 1_28) ) return img...
291
"""simple docstring""" from math import ceil def a__ ( snake_case__ , snake_case__ ) -> Optional[int]: lowerCamelCase = list(range(0 , snake_case__ ) ) lowerCamelCase = [item for sublist in list(device_map.values() ) for item in sublist]...
291
1
def _A ( lowerCAmelCase_ : int ): """simple docstring""" return str(lowerCAmelCase_ ) == str(lowerCAmelCase_ )[::-1] def _A ( lowerCAmelCase_ : int ): """simple docstring""" return int(lowerCAmelCase_ ) + i...
221
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _A ( lowerCAmelCase_ : str , lowerCAmelCase_ : str , **lowerCAmelCase_ : str ): """simple docstring""" lowerCAmelCase__ = AutoConfig...
221
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A__: Any = logging.get_logger(__name__) A__: List[str] = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS mod...
149
def lowerCAmelCase_ ( A_ ,A_): if b == 0: return 1 if (b % 2) == 0: return actual_power(A_ ,int(b / 2)) * actual_power(A_ ,int(b / 2)) else: return a * actual_power(A_ ,int(b / 2)) * actual_power(A_ ,int(b / 2)) def lowerCAmelCase_ ...
149
1
def snake_case_(_UpperCamelCase , _UpperCamelCase ) -> str: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def snake_case_() -> Any: """simple docstring""" assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) =...
369
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 __A = logging.get_logger(__name__) __A = ...
278
0
'''simple docstring''' from pathlib import Path import fire def __magic_name__( lowerCamelCase, lowerCamelCase, lowerCamelCase): __lowerCAmelCase = Path(lowerCamelCase) __lowerCAmelCase = Path(lowerCamelCase) dest_dir.mkdir(exist_ok=lowerCamelCase) ...
174
'''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 ...
174
1
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 ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE_ = logging.get_logger(__name_...
358
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_inputs if is_torch_avai...
193
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpo...
60
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
0
import os from collections.abc import Iterator def __lowercase ( a__ = "." ) -> Iterator[str]: for dir_path, dir_names, filenames in os.walk(a__ ): __SCREAMING_SNAKE_CASE = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] fo...
118
def __lowercase ( a__ = 10_00 ) -> int: __SCREAMING_SNAKE_CASE = -1 __SCREAMING_SNAKE_CASE = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c __SCREAMING_SNAK...
118
1
from math import pi, sqrt, tan def lowerCamelCase_ ( UpperCamelCase__ : float ) -> float: """simple docstring""" if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * s...
90
"""simple docstring""" 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 ...
191
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision f...
275
'''simple docstring''' def lowerCamelCase ( lowerCAmelCase : str ): """simple docstring""" return "".join(chr(ord(lowerCAmelCase ) - 32 ) if 'a' <= char <= 'z' else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
275
1
"""simple docstring""" import os import pytest from attr import dataclass a_ = """us-east-1""" # defaults region @dataclass class __snake_case : """simple docstring""" _lowerCamelCase = 42 _lowerCamelCase = """arn:aws:iam::558105141721:role/sagemaker_execution_...
179
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a_ = logging.get_logger(__name__) a_ = { """shi-labs/nat-mini-in1k-224""": """https://huggingfac...
179
1
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging __lowerCAmelCase : Optional[i...
357
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffuse...
32
0
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __lowerCamelCase ( snake_case__ ,snake_case__ ,**snake_case__ ) -> Optional[int]: """simple docstring""" _SCREAMING_SNAKE_CASE = AutoConf...
306
from queue import PriorityQueue from typing import Any import numpy as np def __magic_name__ ( __lowerCAmelCase : dict , __lowerCAmelCase : str , __lowerCAmelCase : set , __lowerCAmelCase : set , __lowerCAmelCase : dict , __lowerCAmelCase : dict , __lowerCAmelCase : ...
270
0
'''simple docstring''' import datasets from .evaluate import evaluate a_ : List[Any] = """\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, journal={arXi...
361
'''simple docstring''' def a_ ( __snake_case : int = 1000 ) -> int: """simple docstring""" lowerCamelCase_, lowerCamelCase_ =1, 1 lowerCamelCase_ =2 while True: lowerCamelCase_ =0 lowerCame...
6
0
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __lowerCAmelCase : List[str] = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, t...
107
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
313
0
'''simple docstring''' 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_d...
107
'''simple docstring''' import heapq def __lowerCamelCase ( lowerCAmelCase_ ) -> set[int]: _a : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # hea...
107
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .t...
324
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCAmelCase__ = logging.get_logger(__name__) # pylint: disable=invalid-name class _lowerCamelC...
153
0
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __A = logging.get_logger(__name__) __A = R"\n Args:\n input_ids (`torch.LongTensor` of shape `(batch_size, sequ...
368
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWit...
2
0
from __future__ import annotations import math def UpperCAmelCase_ ( __lowerCAmelCase ) -> 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 ...
156
from collections import deque from .hash_table import HashTable class __lowerCAmelCase ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Union[str, Any] , *_snake_case : Union[str, Any] , **_snake_case : Union[str, Any]...
156
1
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 ( ChannelDimension, ImageInput...
350
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES snake_case_ = logging.get_logger(__name__) snake_case_ = OrderedDict( [ # Base mod...
216
0
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
250
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def a ( __a ) -> bool: '''simple docstring''' UpperCamelCase__ :int = int(number**0.5 ) return number == sq * sq def a ( __a , __a...
97
0
"""simple docstring""" import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create...
358
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_fla...
86
0
from typing import Any class A_ : def __init__( self : Optional[int] ,SCREAMING_SNAKE_CASE__ : Any): __lowerCamelCase : Union[str, Any] = data __lowerCamelCase : int = None class A_ : def __init__(...
73
from math import factorial def lowerCamelCase__ (_UpperCAmelCase = 100): return sum(int(_UpperCAmelCase) for x in str(factorial(_UpperCAmelCase))) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
137
0
'''simple docstring''' def _A ( A__ = 1000 ): """simple docstring""" __lowercase , __lowercase = 1, 1 __lowercase = [] for i in range(1 , n + 1 ): __lowercase = prev_numerator + 2 * prev_denominator __lowercase = prev_numerator +...
52
'''simple docstring''' lowerCAmelCase__ = { "joule": 1.0, "kilojoule": 1000, "megajoule": 100_0000, "gigajoule": 10_0000_0000, "wattsecond": 1.0, "watthour": 3600, "kilowatthour": 360_0000, "newtonmeter": 1.0, "calorie_nutr": 4186.8, "kilocalorie_nutr": 418_6800...
52
1
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if i...
255
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase: List[str] = {} try: if not is_s...
255
1
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate...
98
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transfo...
98
1
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowercase : Any = { ...
232
class lowerCamelCase__ : '''simple docstring''' def __init__( self :Union[str, Any] ) -> None: __UpperCamelCase : dict[str, TrieNode] = {} # Mapping from char to TrieNode __UpperCamelCase : List[str] = False def _lowerCa...
232
1
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transform...
237
'''simple docstring''' from __future__ import annotations from typing import Any def __lowerCAmelCase ( UpperCamelCase__ ) -> None: create_state_space_tree(UpperCamelCase__ , [] , 0 ) def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamel...
237
1
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def a_ ( __lowercase : List[Any]=N...
282
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else: _lowerCamelCase ...
282
1
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: List[str] , __lowerCamelCase: Union[str, Any] ): '''simple docstring''' lowercase_ = [1] for i in range(2 , __lowerCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1...
353
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_mvp import MvpTokenizer SCREAMING_...
297
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Dict = { """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", # See al...
50
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase=() , _UpperCAmelCase=None , _UpperCAmelCas...
50
1
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor _lowerCamelCase : List[str] = logging.get_logger(__name__) class __snake_case (_a ): def __init__( self : Optional[Any] , *_UpperCAmelCase : str , **_UpperCAmelCase...
159
def _UpperCAmelCase (UpperCamelCase_ : str , UpperCamelCase_ : str ): '''simple docstring''' _lowerCAmelCase : str = len(UpperCamelCase_ ) + 1 _lowerCAmelCase : List[Any] = len(UpperCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes w...
159
1
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": UpperCAmelCase = input("""Enter image url: """).strip() print(F'''Downloading image from {url} ...''') UpperCAmelCase = BeautifulSoup(requests.get(url).content, """html.pa...
256
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments UpperCAmelCase = logging.getLogger(__name__) @dataclass class UpperCAmelCase_ ( _lowercase...
256
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.se...
107
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller __lowerCAmelCase = 3 def __lowerCamelCase ( lowerCAmelCase_ ) -> int: print('Generating primitive root of p' ) while True: _a : ...
107
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTester...
83
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np a__ : Optional[int] = re.compile(R'\b(a|an|the)\b', re.UNICODE) a__ : int = None def _UpperCamelCase ( ) -> Dict...
80
0
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_ava...
364
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common ...
245
0