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
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, MusicgenProcesso...
100
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
1
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _A : Optional[int] = {"""configuration_plbart""": ["""PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PLBar...
100
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from trans...
100
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A : List[Any] = logging.get_logger(__name__) _A : List[Any] = """▁""" _A : ...
100
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
1
def __snake_case ( lowerCAmelCase_ = 1_0_0_0_0_0_0 ) -> int: SCREAMING_SNAKE_CASE__ = set(range(3 , lowerCAmelCase_ , 2 ) ) primes.add(2 ) for p in range(3 , lowerCAmelCase_ , 2 ): if p not in primes: continue prim...
100
import operator as op def __snake_case ( lowerCAmelCase_ ) -> str: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = lambda lowerCAmelCase_ , lowerCAmelCase_ : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNAKE_CASE__ ...
100
1
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
100
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
100
1
def __snake_case ( lowerCAmelCase_ = 1_0_0 ) -> int: SCREAMING_SNAKE_CASE__ = set() SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ = n + 1 # maximum limit for a in range(2 , lowerCAmelCase_ ): for b in range(2 , ...
100
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 ModelTes...
100
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer _A : int = logging.get_logger(__name__) _A : Tuple ...
100
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_I...
100
1
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlitea import ...
100
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
1
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 _A : List[str] = 1.0_5457_1817E-34 # unit of ℏ : J * s _A : str = 3E8 # unit of c : m * s^-1 def __snake_case ( low...
100
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
100
1
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import UNCONDI...
100
class __snake_case : '''simple docstring''' def __init__( self , A_ , A_ , A_ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = name SCREAMING_SNAKE_CASE__ = value SCREAMING_SNAKE_CASE__ = wei...
100
1
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common ...
100
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
1
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_c...
100
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ......
100
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A : int = logging.get_logger(__name__) _A : List[Any] = { """hustvl/yolos-s...
100
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __snake_case ( ) -> Any: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
100
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
100
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
1
from math import factorial def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> float: if successes > trials: raise ValueError('''successes must be lower or equal to trials''' ) if trials < 0 or successes < 0: raise ValueError(''...
100
from torch import nn def __snake_case ( lowerCAmelCase_ ) -> Tuple: 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'''Unsupported acti...
100
1
import logging from transformers import PretrainedConfig _A : Optional[Any] = logging.getLogger(__name__) _A : List[Any] = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", } ...
100
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
100
1
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class __snake_case ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ : ...
100
1
import math def __lowercase ( snake_case, snake_case = 0, snake_case = 0 ): """simple docstring""" __magic_name__ :int = end or len(snake_case ) for i in range(snake_case, snake_case ): __magic_name__ :Any = i __magic_name__ :Union[str, Any] ...
0
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
100
0
def _A ( _lowercase ) -> int: """simple docstring""" __UpperCamelCase = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def _A ( _lowercase = 1_00 ) -> int: """simple docstring""" __UpperCam...
1
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
0
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = ...
2
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
0
'''simple docstring''' def A_( A : bytes): return "".join([hex(A)[2:].zfill(2).upper() for byte in list(A)]) def A_( A : str): # Check data validity, following RFC3548 # https://www.ietf.org/rfc/rfc3548.txt if (len(A) % 2) != 0: ra...
3
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
0
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class a ( a__ , unittest.TestCas...
4
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from trans...
100
0
'''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 # # U...
5
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
0
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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 ...te...
6
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
0
"""simple docstring""" from manim import * class lowercase_ ( __lowerCAmelCase ): '''simple docstring''' def lowerCAmelCase_ ( self : Union[str, Any] ): _A = Rectangle(height=0.5 , width=0.5 ) _A = Rectangle(height=0.46 , w...
7
import operator as op def __snake_case ( lowerCAmelCase_ ) -> str: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = lambda lowerCAmelCase_ , lowerCAmelCase_ : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNAKE_CASE__ ...
100
0
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers ...
8
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch if is_vision_av...
9
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
100
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 _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = "▁" _lowerCAmelCase ...
10
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 ModelTes...
100
0
'''simple docstring''' from __future__ import annotations def lowerCAmelCase (__A): """simple docstring""" return [ord(__A) - 96 for elem in plain] def lowerCAmelCase (__A): """simple docstring""" return "".join(chr(elem + 96) for elem in encoded) def lowerCAme...
11
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_I...
100
0
from __future__ import annotations def UpperCamelCase ( lowercase_ , lowercase_ ) -> set[str]: '''simple docstring''' lowercase__ , lowercase__ : int = set(lowercase_ ), [start] while stack: lowercase__ : Optional[int] = stack.pop() explo...
12
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
'''simple docstring''' from math import pi, sqrt, tan def UpperCAmelCase__ ( UpperCAmelCase_ : float ) -> float: if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 def UpperCAmelC...
13
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
100
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcesso...
14
class __snake_case : '''simple docstring''' def __init__( self , A_ , A_ , A_ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = name SCREAMING_SNAKE_CASE__ = value SCREAMING_SNAKE_CASE__ = wei...
100
0
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 A : Union[str, Any] = 0B1011001111101100100100000111101110110001100111...
15
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf __A : Dict = logging.get_logger(__nam...
16
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ......
100
0
from math import factorial def __SCREAMING_SNAKE_CASE ( a__ : int = 100 ) -> int: return sum(map(a__ ,str(factorial(a__ ) ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
17
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __snake_case ( ) -> Any: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
100
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig _SCREAMING_SNAKE_CASE = { "albert-base-v1": "https://huggingface.co/albert-base-v1/resolve/main/config.json", "albert-lar...
18
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
0
"""simple docstring""" import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers fr...
19
from torch import nn def __snake_case ( lowerCAmelCase_ ) -> Tuple: 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'''Unsupported acti...
100
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase: Dict = { 'configuration_mobilenet_v2': [ 'MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileNetV2Config', 'Mobi...
20
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
100
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __A ( unittest.TestCase ...
21
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class __snake_case ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ : ...
100
0
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_comm...
22
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
100
0
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 ...test_modeling_tf...
23
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
0
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils imp...
24
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
0
import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py a_ = 'src/transformers' # This is to make sure the transformers module imported is the one in the repo. a...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
0
'''simple docstring''' from __future__ import annotations import numpy as np def _a ( _lowerCamelCase ) -> tuple[np.ndarray, np.ndarray]: """simple docstring""" __snake_case , __snake_case : Optional[Any] = ...
26
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from trans...
100
0
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __A : str = logging.get_logger(__name__) class lowerCamelCase( __snake_case ): '''simple docstring''' def __init__( self , *sna...
27
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
0
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase__( __UpperCamelCase: Tuple ): """simple docstring""" return x + 2 class ...
28
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
0
"""simple docstring""" from math import ceil def lowercase ( lowerCAmelCase__ ,lowerCAmelCase__ ): lowerCamelCase_ = list(range(0 ,lowerCAmelCase__ ) ) lowerCamelCase_ = [item for sublist in list(device_map.values() ) for item in sublist] # Duplicate check lowe...
29
import operator as op def __snake_case ( lowerCAmelCase_ ) -> str: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = lambda lowerCAmelCase_ , lowerCAmelCase_ : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNAKE_CASE__ ...
100
0
def lowerCamelCase__ ( _lowercase = 10 , _lowercase = 22 ): '''simple docstring''' UpperCAmelCase_ : Tuple = range(1 , _lowercase ) UpperCAmelCase_ : Optional[int] = range(1 , _lowercase ) return sum( 1 for power in powers for base in base...
30
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
0
import warnings from ..trainer import Trainer from ..utils import logging lowerCamelCase__ : Union[str, Any] = logging.get_logger(__name__) class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self : Tuple , _low...
31
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
100
0
# Function to print upper half of diamond (pyramid) def A__ ( SCREAMING_SNAKE_CASE_ : int ) -> Any: """simple docstring""" for i in range(0 , SCREAMING_SNAKE_CASE_ ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' ,...
32
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 ModelTes...
100
0
import requests from bsa import BeautifulSoup def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> str: snake_case__ = BeautifulSoup(requests.get(__lowerCAmelCase , params=__lowerCAmelCase ).content , '''html.parser''' ) snake_case...
33
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_I...
100
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, tra...
34
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
def a ( ) -> int: '''simple docstring''' return [ a * b * (1_0_0_0 - a - b) for a in range(1 , 9_9_9 ) for b in range(A__ , 9_9_9 ) if (a * a + b * b == (1_0_0_0 - a - b) ** 2) ][0] if __name__ == "__main__": ...
35
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
100
0
import sys __lowercase : Union[str, Any] = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''668966...
36
class __snake_case : '''simple docstring''' def __init__( self , A_ , A_ , A_ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = name SCREAMING_SNAKE_CASE__ = value SCREAMING_SNAKE_CASE__ = wei...
100
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import c...
37
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_fe...
38
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ......
100
0
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 import ConfigTester f...
39
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __snake_case ( ) -> Any: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
100
0
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class lowerCAmelCase_ ( a__ , ...
40
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase__ = logging.get_logger(__name__) def _A ( A__ ): """simple docstring""" ...
41
from torch import nn def __snake_case ( lowerCAmelCase_ ) -> Tuple: 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'''Unsupported acti...
100
0
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require...
42
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
100
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowerCAmelCase = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenage...
43
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class __snake_case ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ : ...
100
0
'''simple docstring''' from manim import * class UpperCAmelCase__ ( A ): def lowerCamelCase_ ( self : Any ): _lowerCamelCase : Optional[int] = Rectangle(height=0.5,width=0.5 ) _lowerCamelCase : Tuple = Rectangle(height=0.46,width=0.46 )...
44
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
100
0
from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0...
45
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
0
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase = "cpu" , _lowerCamelCase = None ) -> None: '''simple docstring''' _lowerCamelCase : Any = torch.loa...
46
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig f...
47
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
0
'''simple docstring''' import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore UpperCAmelCase__ : Any = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" UpperCAmelCase__ : Dict ...
48
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from trans...
100
0
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[str] = logging.get_logger(__name__) _lowercase : str = { 'xlnet-base-cased': 'https://huggingface.co/xlnet-base-case...
49
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase : Optional[Any] = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
50
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
51
import operator as op def __snake_case ( lowerCAmelCase_ ) -> str: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = lambda lowerCAmelCase_ , lowerCAmelCase_ : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNAKE_CASE__ ...
100
0
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''kakaobrain/alig...
52
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
0
import os def a_ ( ): __lowerCAmelCase = os.path.dirname(os.path.realpath(lowerCAmelCase_ ) ) __lowerCAmelCase = os.path.join(lowerCAmelCase_, 'triangle.txt' ) with open(lowerCAmelCase_ ) as f: __lowerCAmelCase = f.r...
53
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
100
0
import argparse import os import re import packaging.version __lowercase : Tuple ="""examples/""" __lowercase : Optional[Any] ={ """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.c...
54
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 ModelTes...
100
0
import requests SCREAMING_SNAKE_CASE :List[str] = 'YOUR API KEY' def UpperCAmelCase ( a_ , a_ = giphy_api_key ) -> list: """simple docstring""" __A = "+".join(query.split() ) __A = F'''https://api.giphy.com/v1/gifs/search?q={for...
55
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_I...
100
0
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _a : List[Any] = logging.get_logg...
56
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
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 snake_case (UpperCAmelCase__ ) -...
57
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
100
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable()...
58
class __snake_case : '''simple docstring''' def __init__( self , A_ , A_ , A_ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = name SCREAMING_SNAKE_CASE__ = value SCREAMING_SNAKE_CASE__ = wei...
100
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): i...
59
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _A : Dict = get_tests_dir("""fixtures/test_sentencepiece_bpe....
100
0
class __lowerCAmelCase ( _a ): pass class __lowerCAmelCase ( _a ): pass class __lowerCAmelCase : def __init__(self ) -> Optional[int]: '''simple docstring''' snake_case_ : Optional[int] = [ [], [], ...
60
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ......
100
0
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require...
61
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __snake_case ( ) -> Any: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
100
0
import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput snake_case = logging.getLogger(__name__) if is_torch_tpu_available(check_device=False)...
62
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mod...
100
0
from manim import * class a ( lowercase__ ): """simple docstring""" def UpperCAmelCase ( self : Optional[Any] ) -> str: __UpperCAmelCase : Tuple = Rectangle(height=0.5 , width=0.5 ) __UpperCAmelCase : ...
63
from torch import nn def __snake_case ( lowerCAmelCase_ ) -> Tuple: 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'''Unsupported acti...
100
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=False)...
64
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
100
0
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio fr...
65
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class __snake_case ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ : ...
100
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=__snake_case ): _UpperCamelCase : Optional[int] = ["torch"] def __init__( self , *_lowerCAmelCase , **_lowerCAmelCase ): requires_backends(self , ['torc...
66
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
100
0
import argparse snake_case = """docs/source/_static/js/custom.js""" def SCREAMING_SNAKE_CASE__ ( snake_case__ :List[str] ) -> Union[str, Any]: with open(snake_case__ , encoding='utf-8' , newline='\n' ) as f: _lowercase = f.readlines() ...
67
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
0
from manim import * class _A ( UpperCamelCase ): """simple docstring""" def _a ( self : int ) -> Dict: __UpperCAmelCase =Rectangle(height=0.5 , width=0.5 ) __UpperCAmelCase =Rectangle(height=0.46 , width...
68
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( __SCREAMING_SNAKE_CASE , unittest.TestC...
100
0
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer a : int = log...
69
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : Any = {"""configuration_xglm""": ["""XGLM_PRETRAINED_C...
100
0
import heapq as hq import math from collections.abc import Iterator class A: '''simple docstring''' def __init__( self : str , A_ : List[Any] ) -> Any: """simple docstring""" lowerCamelCase_ = str(id_ ...
70
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from trans...
100
0
'''simple docstring''' import torch from torch import nn class _snake_case (nn.Module): def __init__( self ,_snake_case ,_snake_case ,_snake_case ,_snake_case ,_snake_case=1 ,_snake_case=False ): super().__init__() UpperCAmelCase_ : List[Any] = n_...
71
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
0
'''simple docstring''' import os import numpy import onnx def UpperCamelCase ( lowercase_ : Any , lowercase_ : Union[str, Any] ) -> List[Any]: '''simple docstring''' lowercase =a.name lowercase =b.name lowercase ='''''' lowercase ...
72
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
0
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self) -> Optional[Any]: SCREA...
73
import operator as op def __snake_case ( lowerCAmelCase_ ) -> str: SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = lambda lowerCAmelCase_ , lowerCAmelCase_ : int(x / y ) # noqa: E731 integer division operation SCREAMING_SNAKE_CASE__ ...
100
0
import pickle import numpy as np from matplotlib import pyplot as plt class __UpperCamelCase : """simple docstring""" def __init__( self : Optional[int] , _A : Dict , _A : List[Any] , _A : Optional[Any] ,...
74
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
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/LIC...
75
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import M...
100
0
"""simple docstring""" import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaI...
76
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 ModelTes...
100
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json""", } class a__ ( ...
77
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_I...
100
0
'''simple docstring''' from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig,...
78
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
from ...configuration_utils import PretrainedConfig SCREAMING_SNAKE_CASE__ : Tuple = { """google/tapas-base-finetuned-sqa""": ( """https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json""" ), """google/tapas-base-finetuned-wtq""": ( ...
79
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
100
0