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 itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from d...
70
from __future__ import annotations class lowerCamelCase_ : def __init__( self , lowerCamelCase_ , lowerCamelCase_ ) -> int: """simple docstring""" _UpperCamelCase , _UpperCamelCase = text, pattern _UpperCamelCase , _UpperCamelCase =...
147
0
'''simple docstring''' import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, ca...
706
'''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 UpperCamelCase : Any = logging.get_logger(__name__) UpperCa...
610
0
from typing import Any def __UpperCamelCase ( lowercase__ : list , lowercase__ : list , lowercase__ : dict , lowercase__ : dict , lowercase__ : dict , ) -> list: '''simple docstring''' _validation( ...
600
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __UpperCamelCase ( lowercase__ : str ) -> None: '''simple docstring''' lowerCAmelCase_ , lowerCAmelCase_ : str = analyze_text(low...
600
1
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC SCREAMING_SNAKE_CASE__ : Optional[int] = parse(importlib.metadata.version("torch")) def A_ ( UpperCAmelCase__ ,...
509
"""simple docstring""" from math import factorial, pi def A_ ( UpperCAmelCase__ , UpperCAmelCase__ = 30 ) -> float: if not isinstance(UpperCAmelCase__ , (int, float) ): raise ValueError('maclaurin_sin() requires either an int or float for theta' ...
509
1
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _lowercase = {'UserAgent': UserAgent().random} def __UpperCamelCase ( a : Any ) ->dict: s...
342
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _lowercase = logging.get_logger(__name__) class _lowe...
342
1
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def UpperCAmelCase ( A : str...
24
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers....
24
1
'''simple docstring''' def _a (lowercase__ : list , lowercase__ : list , lowercase__ : int ) -> int: """simple docstring""" if len(lowercase__ ) != len(lowercase__ ): raise ValueError('The length of profit and weight must be same.' ...
56
"""simple docstring""" def _snake_case ( lowercase__ = 1 , lowercase__ = 1000 ): _lowerCamelCase : Optional[int] = 1 _lowerCamelCase : List[Any] = 0 for divide_by_number in range(lowercase__ , digit + 1 ): ...
630
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
184
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
184
1
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimens...
236
from __future__ import annotations import os from typing import Any import requests lowerCAmelCase : str = 'https://api.github.com' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user lowerCAmelCase : Optional[Any] = BASE_URL + '/user' # https://github.co...
511
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 b...
718
from PIL import Image def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE : List[str] = image.size _SCREAMING_SNAKE_CASE : Tuple = 0 _SCREAMING_SNAKE_CASE : Dict = image.load() f...
381
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase_ : Any = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCode...
673
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils im...
673
1
from __future__ import annotations import numpy as np def __a ( __UpperCAmelCase ): return np.maximum(0 , A__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
714
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 applic...
148
0
def _SCREAMING_SNAKE_CASE ( lowercase : int = 10 ): '''simple docstring''' if not isinstance(lowercase , lowercase ) or n < 0: raise ValueError('Invalid input' ) lowerCamelCase_ = 10**n lowerCamelCase_ = 2_84...
70
"""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/L...
567
0
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from...
40
'''simple docstring''' from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release <...
40
1
"""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 a : str = loggin...
555
"""simple docstring""" import cva import numpy as np class a_ : def __init__( self : Optional[Any] , __UpperCamelCase : float , __UpperCamelCase : int ) ->Dict: '''simple docstring''' if k in (0.0_4, 0.0_6): ...
555
1
"""simple docstring""" __lowerCAmelCase : Any = range(2, 20 + 1) __lowerCAmelCase : Optional[int] = [10**k for k in range(ks[-1] + 1)] __lowerCAmelCase : dict[int, dict[int, list[list[int]]]] = {} def __lowerCAmelCase ( ...
21
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot...
21
1
"""simple docstring""" 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_com...
88
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Optional[int] = logging.get_logger(__name__) lowerCAmelCase_ : str = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/re...
692
0
"""simple docstring""" a = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a = { 0: '''Sunday''', 1: '''Monday''', 2: '''Tuesday''', 3: '''Wednesday''', 4: '''Thursday''', 5: '''Friday''', 6: '''Saturday''', } def ...
505
"""simple docstring""" import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _snake_case ( _snake_case : List[Any] ) -> Any: '''simple do...
505
1
'''simple docstring''' from collections.abc import Sequence def _a (lowercase__ : Sequence[int] | None = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) __snake_case = ...
56
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_...
184
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase : Tuple = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvNextCo...
707
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) ...
155
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test...
50
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available():...
678
0
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging A = logging.get_logger(__name__) # pylint: disable=invalid-name clas...
712
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # ...
101
0
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_f...
488
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models.b...
488
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """uclanl...
291
def UpperCamelCase ( snake_case__ : str ): '''simple docstring''' __snake_case :List[Any] = hex_num.strip() if not hex_num: raise ValueError("""No value was passed to the function""" ) __snake_case :str = ...
291
1
'''simple docstring''' import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup UpperCAmelCase_ : int = logging.get_logger(...
24
'''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 from lavis.models import load_model_and_preprocess from PIL import Image from transform...
24
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging ...
363
"""simple docstring""" 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 an...
363
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET...
55
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGEN...
89
0
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import T...
703
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, ge...
303
0
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef __lowerCAmelCase = ( '''This m...
466
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __SCREAMING_SNAKE_CASE : str = tuple[int, int] class lowerCamelCase_: '''simple docstring''' def __init__( self , lowerCamelCase__ , lowerCamelCase__...
661
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : int = { """configuration_autoformer""": [ """AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Autoforme...
146
from __future__ import annotations from math import pow, sqrt def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> dict[str, float]: """simple docstring""" if (resistance, reactance,...
146
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ,lowerCAmelCase_ ): @register_to_config def __init__( self : Any , *, A : ...
315
from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Dict = logging.get_logger(__name__) _A : Union[str, Any] = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'studio-ousia/luke...
315
1
"""simple docstring""" import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.ge...
717
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { 'Visual-Attention-Network/van-base': ( 'https://huggingface.co/Visual-Attention-Network/van-base/blo...
348
0
"""simple docstring""" 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 imp...
46
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class snake_case__ : """simple docstring""" _SCREAMING_SNAKE_CASE = field( ...
478
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature f...
704
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCAmelCase_ ( lowercase_ : ...
401
0
def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , ): __magic_name__ : Optional[Any] =[redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for p in parameters ): ...
21
UpperCAmelCase_ : Tuple = 0 # The first color of the flag. UpperCAmelCase_ : Any = 1 # The second color of the flag. UpperCAmelCase_ : str = 2 # The third color of the flag. UpperCAmelCase_ : Tuple = (red, white, blue) def lowerCAmel...
21
1
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_te...
217
"""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, neste...
217
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, Vil...
505
"""simple docstring""" def lowercase (_snake_case ) -> int: '''simple docstring''' __UpperCamelCase = len(_snake_case ) __UpperCamelCase = len(matrix[0] ) __UpperCamelCase = min(_snake_case ,_snake_case ) for row in range(_snake_case ...
505
1
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def _SCREAMING_SNAKE_CASE (__lowerCAmelCase = 1_00_00_00 , __lowerCAmelCase = 10 ) -> int: '''simple docstring''' lowercase_ = defaultdict(_UpperCamelCase ) for outer_width in ra...
715
"""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 impo...
100
0
"""simple docstring""" import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def lowerCamelCase ...
677
"""simple docstring""" from sklearn.metrics import mean_squared_error import datasets UpperCAmelCase = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and B...
677
1
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings __l...
21
"""simple docstring""" def __lowerCAmelCase ( __UpperCamelCase : str ): '''simple docstring''' return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
21
1
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake lowercase_ = numpy.array([0, 0]) lowercase_ = numpy.array([0.5, 0.866_0254]) lowercase_ = numpy.array([1, 0]) lowercase_ = [VE...
669
'''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_...
369
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase : Optional[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() ex...
100
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> int: '''simple docstring''' while a != 0: lowercase_ , lowercase_ = b % a, a return b def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerC...
100
1
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class UpperCAmelCase ( lowercase_): """simple docstring""" lowerCAmelCase_ = """EncodecFeatureExtractor""" lowe...
404
'''simple docstring''' import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import Tokenize...
404
1
"""simple docstring""" def lowercase__ ( snake_case_ :int = 2_000_000 ): __UpperCAmelCase = [0 for i in range(n + 1 )] __UpperCAmelCase = 1 __UpperCAmelCase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in ran...
700
"""simple docstring""" def lowercase__ ( snake_case_ :List[Any] , snake_case_ :str , snake_case_ :Tuple , snake_case_ :Any , snake_case_ :Union[str, Any] , snake_case_ :List[Any] ): if index == r: for j in range(snake_case_ ): print(data[j] , en...
397
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.t...
63
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : str = logging.get_logger(__name__) a : Union[str, Any] = { "microsoft/git-base": "https://huggingface.co/microsoft/git-base...
63
1
import numpy as np import datasets snake_case__ : int = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt ...
710
from typing import Any def _snake_case (__lowercase , __lowercase , __lowercase , __lowercase , __lowercase , ): _validation( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , ...
618
0
from __future__ import annotations from typing import Any def __A ( _lowercase ): '''simple docstring''' create_state_space_tree(_lowercase , [] , 0 ) def __A ( _lowercase , _lowercase , _lowercase ): '''simple d...
484
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ ...
381
0
import math import tensorflow as tf from packaging import version def lowerCamelCase( a__): _SCREAMING_SNAKE_CASE =tf.convert_to_tensor(lowerCAmelCase_) _SCREAMING_SNAKE_CASE =0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0) ,x.dtype))) return x * cdf def lowerC...
703
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
191
0
"""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, ) lowerCAmelCase_ ...
560
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-large/r...
560
1
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCAmelCase_ : lowerCamelCase_ = 42 lowerCamelCase_ = None...
373
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast from ...
373
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 imp...
247
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCAmelCase ( snake_case : int , snake_case : int , snake_case : float = 1 / sqrt(2 ) ): _lowerCAmelCase:Union[str, Any] ...
227
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : str = logging.get_logger(__name__) UpperCamelCase__ : Optional[Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/con...
715
'''simple docstring''' # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def __UpperCamelCase( _A : str ): '''simple docstring''' return 1 / (1 + np.exp(-z ))...
496
0
def __UpperCAmelCase ( lowerCamelCase_ : str ) -> str: """simple docstring""" return " ".join( ''.join(word[::-1] ) if len(snake_case__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod()...
105
import tensorflow as tf from ...tf_utils import shape_list class a ( tf.keras.layers.Layer ): """simple docstring""" def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , ...
401
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __SCREAMING_SNAKE_CASE : Tuple =version.parse(importlib_metadata.version('''nltk''')) if NLTK_VERSION >= version.Version('''3.6.4'''): from nltk import wo...
72
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...f...
72
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging...
96
"""simple docstring""" 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, TruncationStrateg...
586
0
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _a ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case : Any = ...
47
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation Up...
47
1
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake lowerCamelCase : Optional[Any] = numpy.array([0, 0]) lowerCamelCase : Optional[int] = numpy.array([0.5, 0.866_0254]) lowe...
70
import argparse import json import subprocess def _SCREAMING_SNAKE_CASE ( lowercase : Dict , lowercase : List[str] ): '''simple docstring''' lowerCamelCase_ = [] lowerCamelCase_ = ( f"""curl -H \"Accept:...
70
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_determinism, load_numpy, ...
703
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A__ ( __lowerCamelCase = "laptop" ): SCREAMING_SNAKE_CASE_ = F'''https://www.amazon.in/laptop/s?k={product}''' SCREAMING_SNAKE_CASE_ = { '''User-Agent''': '''Mozilla/5.0 (X11;...
597
0
def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
21
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( lowerCamelCase ): # A local function to see if a dot lands in the circle. def is_in_circle(lowerCamelCase , lowerCamelCase ) -> bool:...
21
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import ...
712
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase ): if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": ...
549
0
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class snake_case_ ( lowerCAmelCase ): __lowerCamelCase : List[str] = (EulerDiscreteScheduler,) __lowerCamelCase : ...
345
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching bet...
605
0
'''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 from ...
707
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _snake_case ( a_ ): SCREAMING_SNAKE_CASE : List[Any] = (IPNDMScheduler,) SCREAMING_SNAKE_CASE : Optional[Any] = (('''num...
514
0
"""simple docstring""" from typing import List import numpy as np def __lowercase ( snake_case_ : dict ) ->int: '''simple docstring''' __A : Optional[int] = {key: len(snake_case_ ) for key, value in gen_kwargs.items() if isinstance(snake_case_ ,snake...
177
"""simple docstring""" import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noq...
177
1
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime ...
366
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow h...
366
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( __snake_case : Dict ): if not head: return True # split the list to two parts _A , _A = head.next, head while fast and fast.next: _A = fast.next.next _A = slow.next ...
107
'''simple docstring''' import os lowercase : Tuple = {'I': 1, 'V': 5, 'X': 1_0, 'L': 5_0, 'C': 1_0_0, 'D': 5_0_0, 'M': 1_0_0_0} def __a ( A__ ) -> int: lowerCAmelCase = 0 lowerCAmelCase = 0 while index < len(A__ ) - 1: lowerC...
649
0
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 _lowercase : Union[str, Any] =logging.get_logger(__name__)...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : int =logging.get_logger(__name__) _lowercase : Dict ={ '''facebook/xglm-564M''': '''https://huggingface.co/facebook/xglm-564M/resolve/main/config.json''', # See ...
661
0
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar __magic_name__ : Optional[Any] = TypeVar("""T""") class lowercase__ ( Generic[T] ): """simple docstring""" def __init__( self , ...
102
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", """TableTransfor...
413
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule __lowerCamelCase :Optional[Any] = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: impo...
702
"""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_backbone_c...
42
0
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_u...
345
import unittest from transformers import DonutProcessor _a : Optional[int] = 'naver-clova-ix/donut-base' class a_ ( unittest.TestCase ): def lowerCAmelCase( self : Tuple ): """simple docstring""" snake_case : Option...
598
0
import warnings warnings.warn( '''memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: ''' '''`from accelerate import find_executable_batch_size` to avoid this warning.''', FutureWarning, )
189
def __lowerCAmelCase ( snake_case : int = 1000000 ) -> int: __lowerCamelCase: Union[str, Any] = set(range(3 , snake_case , 2 ) ) primes.add(2 ) for p in range(3 , snake_case , 2 ): if p not in primes: continue ...
189
1
"""simple docstring""" __lowerCAmelCase : List[Any] =[ """Audio""", """Array2D""", """Array3D""", """Array4D""", """Array5D""", """ClassLabel""", """Features""", """Sequence""", """Value""", """Image""", """Translation""", """Translatio...
359
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : int =logging.get_logger(__name__) __lowerCAmelCase : Optional[Any] ={ """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base...
359
1
'''simple docstring''' from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatur...
713
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position _snake_case : Union[str, Any] = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.python_vers...
493
0
'''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 ( i...
649
'''simple docstring''' def __a ( A__ , A__ ) -> int: return int((input_a, input_a).count(0 ) == 0 ) def __a ( ) -> None: assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 ...
649
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar UpperCAmelCase : Any = TypeVar('T') UpperCAmelCase : str = TypeVar('U') class lowerCamelCase (Generic[T, U] ): def __init__( self ...
705
'''simple docstring''' import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor UpperCAmelCase : str = logging.getLogger(__name__) UpperCAmelCas...
47
0
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore lowerCAmelCase__ = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" lowerCAmelCase__ = [file for file in filepaths if file != file...
514
from PIL import Image def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Image , SCREAMING_SNAKE_CASE_: int ) -> Image: '''simple docstring''' A__ = (2_5_9 * (level + 2_5_5)) / (2_5_5 * (2_5_9 - level)) def contrast(SCREAMING_SNAKE_CASE_: i...
514
1
from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : str ) -> list[int]: return [ord(UpperCAmelCase_ ) - 9_6 for elem in plain] def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : list[int] ) -> str: return "".join(chr(elem + 9_6 ...
431
import gc import unittest from transformers import CTRLConfig, 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_common import Mode...
431
1
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel snake_case__ : Union[str, Any] = False snake_case__ : int = True snake_case__ : List[str] = ...
392
def lowercase ( _lowerCAmelCase ): UpperCAmelCase__ = len(_lowerCAmelCase ) while cur > 1: # Find the maximum number in arr UpperCAmelCase__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi UpperCAmelCase__ = arr[mi::-1] + arr[mi + 1 : len(_...
392
1
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcessor,...
717
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __snake_case :List[str] = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @dataclass class _A : ...
60
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule __SCREAMING_SNAKE_CASE = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys __SCREAMING_SNAKE_C...
688
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex __SCREAMING_SNAKE_CASE = logging.getLogger(__name__) class lowerCAmelCase__ : """simple...
688
1
from math import isqrt, loga def snake_case__ ( UpperCAmelCase : int ): lowerCAmelCase__ :Optional[int] = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , Up...
111
def snake_case__ ( UpperCAmelCase : float ): if edge <= 0 or not isinstance(UpperCAmelCase , UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((2_5 + 1_0 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def snake_case__ ...
111
1
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel _UpperCamelCase =...
341
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> np.ndarray: return input_array.reshape((input_array.size, 1) ) def ...
652
0
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils import DUMMY_UNKNOWN_IDE...
588
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impo...
588
1
from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=__magic_name__ ): '''simple docstring''' lowercase_ = ["""torch"""] def __init__( self , *lowercase__ , **lowercase__ ): '''simple docstrin...
184
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class lowerCAmelCase__ ( __magic_name__ ): ''...
184
1
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _snake_case = { "configuration_perceiver": ["PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PerceiverConfig", "Perce...
307
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, ) ...
249
0
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowerCamelCase_ : Dict = HfApi() lowerCamelCase_ : str = {} # fmt: off lowerCamelCase_ : Tuple = torch.tensor([ -0.7515, -1.6883, 0.2420, 0....
710
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.dummy_torch_an...
345
0
"""simple docstring""" import os def A_ ( snake_case_ : Any ): '''simple docstring''' UpperCamelCase : str = len(grid[0] ) UpperCamelCase : int = len(snake_case_ ) UpperCamelCase : Optional[int] = 0 UpperCamel...
499
"""simple docstring""" import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGE...
499
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 AutoImageProcessor, ViTImageProcessor from transformers.testing_utils imp...
426
'''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 i...
426
1
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _snake_case = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def __snake_case ( SCREAMING_SNAKE_CASE: s...
580
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_dimen...
61
0
def UpperCamelCase( lowercase_ , lowercase_ ) -> Tuple: '''simple docstring''' return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def UpperCamelCase( lowercase_ , lowercase_=0 ) -> str: '''simple docstring''' ...
721
# 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 ap...
161
0
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch ...
90
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class UpperCAmelCase__ ( unittest.TestCase ): """simple docstring""" def lowercase...
493
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError('\'str...
705
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> Union[str, Any]: stooge(SCREAMING_SNAKE_CASE , 0 , len(SCREAMING_SNAKE_CASE ) - 1 ) return arr def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -...
311
0
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig __SCREAMING_SNAKE_CASE ={ """facebook/maskformer-swin-base-ade"""...
234
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTt...
234
1
"""simple docstring""" from dataclasses import dataclass from typing import Dict, 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 .attention_processor import AttentionProcessor, Attn...
254
"""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 ModelMixin ...
254
1
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class lowercase__ : '''simple docstring''' _snake_case = 42 _snake_case = None _snake_case = None ...
212
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
683
0
import math def __lowerCamelCase ( __a : int ) -> list[int]: _lowercase =[] _lowercase =2 _lowercase =int(math.sqrt(__a ) ) # Size of every segment _lowercase =[True] * (end + 1) _lowercase =[] while start <= end: if temp[start] is True: in_prime.appe...
594
import json from typing import TYPE_CHECKING, 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_blenderbot import Blende...
594
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 fro...
207
'''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...
207
1
import qiskit def lowerCamelCase_ ( lowerCamelCase__ = 2 ): lowerCamelCase_ = qubits # Using Aer's simulator lowerCamelCase_ = qiskit.Aer.get_backend("aer_simulator" ) # Creating a Quantum Circuit acting on the q register lowerCamelCase_ =...
715
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import ...
313
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : Optional[Any] =logging.get_logger(__name__) _lowercase : Dict ={ '''roberta-base''': '''htt...
305
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import ...
305
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase = 1_00 ) -> int: '''simple docstring''' lowercase_ = set() lowercase_ = 0 lowercase_ = n + 1 # maximum limit for a in range(2 , __lowerCAmelCase ): for ...
100
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from ....
100
1