code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
"""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/LICENSE...
139
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
def lowercase ( _lowerCAmelCase ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
392
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
"""simple docstring""" import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, re...
434
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
from torch import nn def SCREAMING_SNAKE_CASE__ ( snake_case__ :str ) -> int: if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F"""Unsupport...
67
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
def _a ( lowerCAmelCase , lowerCAmelCase )-> Any: print('\nThe shortest path matrix using Floyd Warshall algorithm\n' ) for i in range(UpperCamelCase__ ): for j in range(UpperCamelCase__ ): if dist[i][j] != float('inf' ): print(int(dist[i][j] ) , end='...
360
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeli...
641
0
'''simple docstring''' import math import qiskit def __A ( a_ : int = 1 ,a_ : int = 1 ,a_ : int = 1 ): if ( isinstance(UpperCamelCase__ ,UpperCamelCase__ ) or isinstance(UpperCamelCase__ ,UpperCamelCase__ ) or isinstance(UpperCamelCas...
525
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger lowerCAmelCase__ = "<<<<<<< This should probably be modified because it mentions: " lowerCAmelC...
645
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
'''simple docstring''' # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won...
476
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
0
"""simple docstring""" from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets __UpperCAmelCase : List[Any] = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Und...
584
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a : List[Any] = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetCo...
63
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0
# 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/licenses/LICENSE-2.0 # # Unless required by applica...
164
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pip...
139
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration snake_case__ : int = 5_0_0_0_0_0 snake_case__ : List[Any] = os.path.split(__file__) snake_case__ : Any = os.pa...
392
import unittest from transformers import XLMConfig, 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 ModelTesterMixin, ids_...
641
0
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common im...
434
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
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 Optiona...
67
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
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 ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
360
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
0
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function lowerCAmelCase = 1.054_571_817e-34 # unit of ℏ : J * s lowerCAmelCase = 3e8 # unit of c : m * s^-1 def...
525
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 transformers import ( AutoTokeniz...
641
0
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class...
645
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
0
'''simple docstring''' import os import re import warnings 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_ta import ...
476
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase : Optional[Any] = { "configuration_whi...
584
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
641
0
from __future__ import annotations def lowerCamelCase__ ( __lowerCamelCase : str ): return [ord(UpperCamelCase__ ) - 96 for elem in plain] def lowerCamelCase__ ( __lowerCamelCase : list[int] ): return "".join(chr(elem + 96 ...
63
_lowercase : Dict = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batche...
641
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() snake_case_ = logging.get_logger(__name__) snake_case_ = [ ["attention", "attn"], ["encoder_attention", "e...
164
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
0
"""simple docstring""" import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict impo...
139
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
def lowercase ( _lowerCAmelCase ): if num <= 0: raise ValueError("""Input must be a positive integer""" ) UpperCAmelCase__ = [True] * (num + 1) UpperCAmelCase__ = 2 while p * p <= num: if primes[p]: for i in range(p * p , num + 1 , Upp...
392
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE...
434
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
def SCREAMING_SNAKE_CASE__ ( snake_case__ :str ) -> bool: _lowercase = [int(UpperCamelCase__ ) for i in ip_va_address.split('.' ) if i.isdigit()] return len(UpperCamelCase__ ) == 4 and all(0 <= int(UpperCamelCase__ ) <= 254 for octet in octets ) if __name__ == "__m...
67
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
import string from math import logaa def _a ( lowerCAmelCase , lowerCAmelCase )-> int: SCREAMING_SNAKE_CASE_ = document.translate( str.maketrans('' , '' , string.punctuation ) ).replace('\n' , '' ) SCREAMING_SNAKE_CASE_ ...
360
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeli...
641
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { "google/bigbird-r...
525
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
"""simple docstring""" import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorStat...
645
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def lowerCamelCase (_SCREAMING_SNAKE_CASE...
476
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
0
"""simple docstring""" from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __lowerCAmelCase (__snake_case...
584
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
0
import unittest from transformers import XLMConfig, 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...
63
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() snake_case_ = logging.get_logger('''transformers.models.speecht5''') def snake_case__ ( SCREAMING_SNAKE_CASE_ : Optional[int...
164
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
"""simple docstring""" import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetY...
139
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case ( __snake_case ): '''simple docstring''' ...
392
import unittest from transformers import XLMConfig, 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 ModelTesterMixin, ids_...
641
0
"""simple docstring""" 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 impor...
434
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A_ ( __snake_case ): ...
67
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
0
from timeit import timeit def _a ( lowerCAmelCase )-> int: if number < 0: raise ValueError('the value of input must not be negative' ) SCREAMING_SNAKE_CASE_ = 0 while number: number &= number - 1 result += 1 return result def ...
360
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
0
'''simple docstring''' from math import pi def __A ( a_ : int ,a_ : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
525
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 transformers import ( AutoTokeniz...
641
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "naver-clova-ix/donut-base": "https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json", # Se...
645
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
0
'''simple docstring''' def lowerCamelCase (_SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : list[list[int]] ): def update_area_of_max_square(_SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ) -> int: # BASE CASE if row >=...
476
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
0
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __UpperCAmelCase : Optional[Any] = get_tests_d...
584
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
641
0
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
63
_lowercase : Dict = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batche...
641
0
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
164
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
0
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) class lowerCamelCase...
139
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
import warnings from functools import wraps from typing import Callable def lowercase ( _lowerCAmelCase ): @wraps(UpperCamelCase__ ) def _inner_fn(*_lowerCAmelCase , **_lowerCAmelCase ): warnings.warn( (F'''\'{fn.__name__}\' is experimental and might be su...
392
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( I...
434
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def SCREAMING_SNAKE_CASE__ (...
67
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.nu...
360
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeli...
641
0
'''simple docstring''' def __A ( a_ : int ,a_ : int ): return int((input_a, input_a).count(0 ) == 0 ) def __A ( ): assert and_gate(0 ,0 ) == 0 assert and_gate(0 ,1 ) == 0 assert and_gate(1 ,0 ) == 0 assert and_gate(1 ,1 ) == ...
525
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class SCREAMING_SNAKE_CASE__ : """simple docstring""" a : Tuple =42 # [batch_size x 3] a : Optional[Any] =42 # [batch_size x 3] ...
645
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import to...
476
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
0
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer __UpperCAmelCase : Union[str, Any...
584
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[Any] = {"configuration_wavlm": ["WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "WavLMConfig"]} try: if not is_torch_available(): rais...
63
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREAMING_SNAKE_CASE__ (unittest.TestCase ): ...
164
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
"""simple docstring""" import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def lowerCamelCase ( _UpperCamelCase ...
139
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import to...
392
import unittest from transformers import XLMConfig, 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 ModelTesterMixin, ids_...
641
0
"""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/LICENSE-2...
434
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) snake_case = 2_9_9_7_9_2_4_5_8 # Symbols snake_case = symbols("""ct x y z""") def SCREAMING_SNAKE_CASE__ ( snake_case__ :float ) -> float: ...
67
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
0
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _a ( lowerCAmelC...
360
def _lowerCAmelCase ( UpperCamelCase__: Union[str, Any] ) -> Dict: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
641
0
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_co...
525
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 transformers import ( AutoTokeniz...
641
0
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class SCREAMING_SNAKE_CASE__ ( unittest.TestCase , __snake_case ): """simple docstring""" def lowercase__ ( self ): """si...
645
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowercase : List[str] = logging.get_logger(__name__) _lowercase : int = [ ["attention", "attn"],...
641
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : str = logging.get_logger(__name__) class __UpperCamelCase ( __snake_case ): A_ = "encoder-decoder" A_ = True ...
476
import requests from bsa import BeautifulSoup def _lowerCAmelCase ( UpperCamelCase__: str = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" A = BeautifulSoup(requests.get(UpperCamelCase__ ).text , """html.parser""" ) A ...
641
0
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def A ( _A ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
584
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
641
0
def lowerCamelCase__ ( __lowerCamelCase : int ): if upper_limit < 0: raise ValueError("""Limit for the Catalan sequence must be ≥ 0""" ) __UpperCAmelCase : Optional[Any] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 __Upper...
63
_lowercase : Dict = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batche...
641
0
import math import os import sys def snake_case__ ( SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' lowercase__ : Any = '' try: with open(UpperCamelCase__ , 'rb' ) as binary_file: lowercase__ : Any = binar...
164
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
0
"""simple docstring""" from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake UpperCAmelCase : List[str] = numpy.array([0, 0]) UpperCAmelCase : Tuple = numpy.array([0.5, 0.8660254]) UpperCAmelCase ...
139
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _lowercase : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1),...
641
0
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, nested_sim...
392
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCH...
641
0
"""simple docstring""" import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREA...
434
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TF...
67
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
641
0
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _a ( lowerCAmelCase )-> Optional[int]: SC...
360
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.modeli...
641
0
'''simple docstring''' import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class lowerCa...
525
from ..utils import DummyObject, requires_backends class _UpperCamelCase ( metaclass=__snake_case ): """simple docstring""" lowerCAmelCase = ['note_seq'] def __init__( self , *a__ , **a__ ) -> Optional[int]: requires_backends(self , ["""n...
641
0
"""simple docstring""" from random import randint from tempfile import TemporaryFile import numpy as np def a__ ( SCREAMING_SNAKE_CASE : Union[str, Any] , SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str ): '''simple docstring''' ...
645
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
0
'''simple docstring''' from sklearn.metrics import fa_score import datasets __lowercase : Union[str, Any] = "\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" __lowercase : Any =...
476
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import ...
641
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fro...
584
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _lowerCAmelCase ( UpperCamelCase__: Any ) -> Optional[int]: ...
641
0
import numpy as np def lowerCamelCase__ ( __lowerCamelCase : np.ndarray , __lowerCamelCase : float ): return np.where(vector > 0 , UpperCamelCase__ , (alpha * (np.exp(UpperCamelCase__ ) - 1)) ) if __name__ == "__main__": ...
63
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optio...
641
0
from ....configuration_utils import PretrainedConfig from ....utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", # See all M-CTC-T models at https:/...
164
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
"""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 OnnxConfig...
139
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
import os import sys snake_case__ : List[Any] = os.path.join(os.path.dirname(__file__), '''src''') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Auto...
392
import unittest from transformers import XLMConfig, 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 ModelTesterMixin, ids_...
641
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=__snake_case ): """simple docstring""" __snake_case = ["""sentencepiece"""] def __init__( self , *_lowercase , **_lowercase ) -...
434
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research...
641
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list ...
642
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets __UpperCAmelCase = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It ...
642
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_at...
642
"""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_...
642
1
"""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/LICE...
642
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCAmelCase ( _UpperCamelCase ): # to overwrite a...
642
1
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __UpperCAmelCase ( _UpperCamelCase ): __lowerCamelCase : str = (KDPMaDiscreteScheduler,) ...
642
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '...
642
1
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_...
642
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __UpperCAmelCase = ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def lowercase__ ( lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : str...
642
1
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() __UpperCAmelCase = l...
642
"""simple docstring""" import functools def lowercase__ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str ) -> int: '''simple docstring''' a__ : Any = len(lowerCAmelCase__ ) a__ : Optional[int] = len(lowerCAmelCase__ ) @functools.cache d...
642
1
"""simple docstring""" import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_sub...
642
"""simple docstring""" def lowercase__ ( lowerCAmelCase__ : str ) -> list[int]: '''simple docstring''' a__ : List[str] = [0 for i in range(len(lowerCAmelCase__ ) )] # initialize interval's left pointer and right pointer a__ , a__ : int = 0, 0 for i in ra...
642
1
"""simple docstring""" import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class __UpperCAmelCase ( unittest.TestCase ...
642
"""simple docstring""" import os import unicodedata 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 SPIECE_UNDERLINE, logging __UpperCAmelCase = loggi...
642
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet...
642
"""simple docstring""" import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def lowercase__ ( lowerCAmelCase__ : Union[str...
642
1
"""simple docstring""" import math def lowercase__ ( lowerCAmelCase__ : int ) -> bool: '''simple docstring''' return math.sqrt(lowerCAmelCase__ ) * math.sqrt(lowerCAmelCase__ ) == num def lowercase__ ( lowerCAmelCase__ : int ) -> bool: '...
642
"""simple docstring""" import os def lowercase__ ( ) -> Optional[Any]: '''simple docstring''' with open(os.path.dirname(lowerCAmelCase__ ) + "/p022_names.txt" ) as file: a__ : Optional[int] = str(file.readlines()[0] ) a__ : Optional[int] = names.repla...
642
1
"""simple docstring""" import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCAmelCase ( _UpperCamelCase ): # to overwrite a...
642
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging __UpperCAmelCase = logging.get_logger(__name__) def lowercase__ ( lowerCAmelCase__ : Union[tf.Tensor, np.ndarray] ) -> List[int]: '...
642
1
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) __UpperCAmelCase = pytest.mark.integration @pytest.mark.parametrize...
642
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffus...
642
1
"""simple docstring""" from math import factorial def lowercase__ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> int: '''simple docstring''' # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative...
642
"""simple docstring""" from __future__ import annotations def lowercase__ ( lowerCAmelCase__ : int ) -> list[int]: '''simple docstring''' a__ : Tuple = [True] * limit a__ : Tuple = False a__ : int = False a__ : Tuple = True for i in range(3...
642
1
"""simple docstring""" import csv import tweepy # Twitter API credentials __UpperCAmelCase = '''''' __UpperCAmelCase = '''''' __UpperCAmelCase = '''''' __UpperCAmelCase = '''''' def lowercase__ ( lowerCAmelCase__ : str ) -> None: '''simple docstr...
642
"""simple docstring""" __UpperCAmelCase = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def lowercase__ ( lowerCAmelCase__ : Dict , lowerCAmelCase__ : Optional[in...
642
1
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoin...
642
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __UpperCAmelCase ( unittest.TestCase , _UpperCamelCase ): def UpperCAmelCase ( self : Dict ) -> List[Any]: '''simple do...
642
1
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info...
642
"""simple docstring""" import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow __UpperCAmelCase = False class __UpperCAmelCase ( unittest.TestCase ...
642
1
"""simple docstring""" import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, ren...
642
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __UpperCAmelCase = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encoder''', '''attn''': '...
642
1
"""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_...
642
"""simple docstring""" from __future__ import annotations def lowercase__ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> tuple[int, int]: '''simple docstring''' if b == 0: return (1, 0) ((a__) , (a__)) : List[Any] = extended_euclid(lowerCA...
642
1
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __UpperCAmelCase = tuple[int, int] class __UpperCAmelCase : def __init__( self : Union[str, Any] , a_ : set[int] , a_ : Mapping[EdgeT, int] ) -> None: ...
642
"""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 __UpperCAmelCase = logging.get_logger(__name__) clas...
642
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__...
642
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowercase__ ( lowerCAmelCase__ : int ) -> int: '''simple docstring''' a__ : Tuple = prime_factors(lowerCAmelCase__ ) if is_square_free(lowerCA...
642
1