code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from tra...
235
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : List[Any] = {'configuration_xlnet': ['XL...
51
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.mode...
710
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensio...
20
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging UpperCam...
387
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel,...
387
1
'''simple docstring''' from collections.abc import Callable import numpy as np def _A ( snake_case__ : Callable , snake_case__ : float , snake_case__ : float , snake_case__ : float , snake_case__ : float ): snake_case__ : Dict = int(np.ceil((x_end - xa) / step_size...
702
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else:...
694
0
from PIL import Image def snake_case__ ( lowercase ): lowerCAmelCase_: Union[str, Any] = image.size lowerCAmelCase_: Union[str, Any] = 0 lowerCAmelCase_: int = image.load() for i in range(lowercase ): for j in range(lowercase ): lowerCAmelCas...
613
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
504
0
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...te...
149
def snake_case_ ( lowercase__ : int ): '''simple docstring''' _lowerCAmelCase =[1] _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase =0, 0, 0 _lowerCAmelCase =ugly_nums[ia] * 2 _lowerCAmelCase =ugly_nums[ia] * 3 _lowerCAme...
149
1
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = '▁' SCREAMI...
300
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch SCREAMING_SNAKE_CASE_ ...
300
1
"""simple docstring""" import os lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 1_00, '''D''': 5_00, '''M''': 10_00} def UpperCAmelCase ( A : str ): '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase ...
717
"""simple docstring""" import os lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 1_00, '''D''': 5_00, '''M''': 10_00} def UpperCAmelCase ( A : str ): '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase ...
24
0
'''simple docstring''' # XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _lowerCAmelCase :Optional[Any] = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)...
251
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICE...
251
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase_ = { '''configuration_vivit''': ['''VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VivitConfig'''], }...
713
'''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 lowercase_ = logging.get_logger(__name__) lowerca...
58
0
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
622
from __future__ import annotations def _lowerCAmelCase ( A__ , A__ = None ): lowercase__ = word_bank or [] # create a table lowercase__ = len(A__ ) + 1 lowercase__ = [] for _ in range(A__ ): table.append([] ) # seed value lowercas...
622
1
UpperCamelCase_ = frozenset( [ "prompt", "height", "width", "guidance_scale", "negative_prompt", "prompt_embeds", "negative_prompt_embeds", "cross_attention_kwargs", ] ) UpperCamelCase_ = frozenset(["prompt", "negative_prompt"]) ...
712
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def A ( ) -> Optional[int]: '''simple docstring''' raise RuntimeError('''CUDA out of memory.''' ) ...
561
0
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) ...
449
from math import factorial, pi def lowerCamelCase__ ( _a , _a = 30): if not isinstance(_a , (int, float)): raise ValueError("maclaurin_sin() requires either an int or float for theta") if not isinstance(_a , _a) or accuracy <= 0: raise ValueError("maclaurin_sin() requires a...
25
0
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilB...
715
__magic_name__ : List[Any] = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_0000)] def lowercase__ ( _UpperCamelCase) -> int: """simple docstring""" UpperCamelCase = 0 while number: # Increased Speed Sligh...
410
0
"""simple docstring""" import torch from diffusers import DiffusionPipeline class a ( _lowerCamelCase ): """simple docstring""" def __init__( self , snake_case_ , snake_case_ ) -> Dict: super().__init__() self.register_modules(un...
426
import unittest from knapsack import greedy_knapsack as kp class _A ( unittest.TestCase ): def __a ( self : List[Any] ) -> Optional[int]: """simple docstring""" lowercase : Dict = [10, 20, 30, 40, ...
217
0
'''simple docstring''' a_ : str = range(2, 20 + 1) a_ : Any = [10**k for k in range(ks[-1] + 1)] a_ : dict[int, dict[int, list[list[int]]]] = {} def __snake_case ( UpperCAmelCase_ : Any , UpperCAmelCase_ : int ...
445
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : List[Any] = ...
445
1
'''simple docstring''' from __future__ import annotations from typing import TypedDict class _snake_case ( lowercase_ ): lowerCAmelCase_ : str lowerCAmelCase_ : int def UpperCamelCase_( snake_case : str ): '''simple docstring''' if not isinstance(...
400
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Tuple ...
400
1
"""simple docstring""" import os __lowerCamelCase = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 1_00, "D": 5_00, "M": 10_00} def UpperCAmelCase ( UpperCamelCase__ ): """simple docstring""" A__ = 0 A__ = 0 ...
536
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_avai...
536
1
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py __lowerCamelCase = """src/diffusers""" # Matches is_xxx_available() __lowerCamelCase = re....
608
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a : ...
218
0
import os from datetime import datetime as dt from github import Github UpperCamelCase_ = [ "good first issue", "feature request", "wip", ] def _UpperCAmelCase ( ): """simple docstring""" __lowerCAmelCase = Github(os.environ["GITHUB_TOKEN"] ) __lowerCAmelCase ...
712
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class a ( unittest.TestCase ): def UpperCAmelCa...
376
0
"""simple docstring""" from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("repo_id" , ["canonical_dataset_name", "org-name/dataset-name"] ) @pytest.mark.parametrize("path" , ["filename.csv", "filename with blanks.c...
516
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : int = get_logger(__name__) A : Dict = r'\n Args:\n input_ids (`jnp....
516
1
class _a : def __init__( self: Tuple , UpperCamelCase_: Any = "" , UpperCamelCase_: Dict = False ) -> Optional[Any]: """simple docstring""" lowercase__ = {} # A node will be a leaf if the tree contains it...
716
import requests from bsa import BeautifulSoup def _a ( SCREAMING_SNAKE_CASE = "AAPL" ): """simple docstring""" lowercase__ = f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}' lowercase__ = BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE ).text , '''html.par...
429
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swinv...
459
'''simple docstring''' from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
459
1
"""simple docstring""" import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
718
"""simple docstring""" from math import sqrt def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = 0 for i in range(1 , int(sqrt(UpperCamelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCamelCase_ ): total += i + n // i ...
248
0
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transfo...
52
"""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 A = logging.get_logger(__name__) A ...
52
1
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils imp...
711
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase__ ( metaclass=UpperCAmelCase_ ): lowercase__ : Union[str, Any] = ["""torch""", """transformers""", """onnx"""] def __init__( self , *UpperCamelCase__ , **UpperCamelC...
261
0
'''simple docstring''' import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline __a = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value network 'scale_g...
494
'''simple docstring''' from __future__ import annotations def __UpperCAmelCase ( a_: str ): return [ord(a_ ) - 96 for elem in plain] def __UpperCAmelCase ( a_: list[int] ): return "".join(chr(elem + 96 ) for elem in encoded ) def __UpperCAmelCase ...
494
1
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor A = logging.get_logger(__name__) class lowercase__ ( __SCREAMING_SNAKE_CASE ): def __init__( self : Tuple , *_lowercase : List[str] , **_...
277
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = {"configuration_mmbt": ["MMBTConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass...
277
1
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from tra...
43
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAn...
159
0
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class __snake_case ( nn.Module ):...
706
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available...
604
0
def __lowerCamelCase ( _lowercase ) -> list: UpperCamelCase = len(_lowercase ) for _ in range(_lowercase ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: UpperCamelCase , UpperCa...
282
# 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...
282
1
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import ...
716
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tenso...
620
0
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = "x" , SCREAMING_SNAKE_CASE_ = 10**-10 , SCREAMING_SNAKE_CASE_ = 1 , ) ->...
591
'''simple docstring''' import gc import threading import time import psutil import torch class _a : """simple docstring""" def __init__( self ) -> str: _SCREAMING_SNAKE_CASE = psutil.Process() _SCREAMING_SNAKE_CASE = False ...
591
1
from math import factorial def __UpperCAmelCase ( __A = 2_0 ) -> int: '''simple docstring''' UpperCAmelCase__ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... UpperCAmelCase__ ...
703
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowercase__ ( __SCREAMING_SNAKE_CASE ): def __init__( self : Dict , _lowercase : int , ...
277
0
'''simple docstring''' def UpperCamelCase__ ( _lowercase : Union[str, Any] ) -> Optional[int]: __UpperCAmelCase: Dict = len(_lowercase ) for i in range(length - 1 ): __UpperCAmelCase: str = i for k in range(i + 1 , _lowercase ): if collect...
523
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/GPTSAN-2.8B-sp...
523
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass A__ = (3, 9, -11, 0, 7, 5, 1, -1) A__ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __UpperCamelCase : _lowercase : int _lowercase : Node | None class __U...
184
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING: ...
184
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __snake_case = logging.get_logger(__name__) __snake_case = { """shi-labs/dinat-...
178
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def __lowerCAmelCase ( lowercase : Optional[int] ...
178
1
'''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, get_resize_output_image_size, normalize, rescale, resize, to_channe...
415
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class __A ( UpperCamelCase__ ): a__ : Optional[int]...
415
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __lowerCamelCase = logging.get_logger(__name__) class A__ ( _snake_case ): def __init__( self , *UpperCamelCase__ , **UpperCamelC...
288
'''simple docstring''' import csv import tweepy # Twitter API credentials __lowerCamelCase = '''''' __lowerCamelCase = '''''' __lowerCamelCase = '''''' __lowerCamelCase = '''''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> None: # ...
288
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __lowerCamelCase = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (trapmf(), gbel...
455
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and ...
455
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform ...
564
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeIma...
255
0
def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase ): _SCREAMING_SNAKE_CASE : int = len(__lowerCamelCase ) _SCREAMING_SNAKE_CASE : int = len(__lowerCamelCase ) _SCREAMING_SNAKE_CASE : int = ( first_str_length ...
711
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ ={ 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionConfig', ...
381
0
from __future__ import annotations def lowercase ( a ): '''simple docstring''' if len(a ) == 0: return [] SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ :List[str] = min(a ), max(a ) SCREAMING_SNAKE_CASE_ :Union[str, Any] = int(max_value - min_value )...
631
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPEN...
631
1
'''simple docstring''' import math class _lowercase : '''simple docstring''' def lowerCAmelCase__ ( self ,lowerCamelCase_ ,lowerCamelCase_ ) -> int: '''simple docstring''' UpperCAmelCase__ : Tuple = 0.0 UpperCAmelCase__ ...
701
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : str...
496
0
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 # # ...
367
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowerCamelCase : str = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deformable_detr/cuda/ms_de...
367
1
"""simple docstring""" from graphs.minimum_spanning_tree_kruskal import kruskal def lowercase_ ( ) -> int: '''simple docstring''' __lowerCamelCase : Any = 9 __lowerCamelCase : Dict = [ [0, 1, 4], [0, 7, 8], [1, 2, 8],...
366
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow h...
366
1
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def lowerCAmelCase_ ( _lowerCamelCase: str , _lowerCamelCase: str ): __SCREAMING_SNAKE_CASE : Any = list(_lowerCamelCase ) __SCREAMING_SNAKE_...
578
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamel...
578
1
'''simple docstring''' def a_ ( __UpperCAmelCase ) -> list[list[int]]: """simple docstring""" snake_case: Optional[Any] =[] if len(__UpperCAmelCase ) == 1: return [nums.copy()] for _ in range(len(__UpperCAmelCase ) ): ...
703
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, ...
347
0
import math import unittest from transformers import BioGptConfig, 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_comm...
176
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( Co...
64
0
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class UpperCamelCase__: def __init__( self : Union[str, Any] , lowerCAmelCase : list[tuple[float, float]] )-> Any: """simple docstring""" UpperCAme...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
from typing import Dict, Optional import numpy as np import datasets a = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For binary (two classes) or multi-class segme...
687
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a = logging.get_logger(__name__) a = { """bert-base-uncased""": """https://huggingface.co/be...
687
1
'''simple docstring''' import math def __lowercase (_lowercase ) -> list: """simple docstring""" __lowerCamelCase : Any = [True] * n __lowerCamelCase : Optional[Any] = False __lowerCamelCase : List[str] = False ...
483
'''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 ...
483
1
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _snake_case ( UpperCAmelCase_ ): def lowercase__ ( self): '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2...
12
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A_ = { "configuration_vision_text_dual_encoder": ["VisionTextDualEncoderConfig"], "processing_vision_text_dual_encoder...
393
0
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance lowerCamelCase__ = 637_8137.0 lowerCamelCase__ = 635_6752.31_4245 lowerCamelCase__ = 637_8137 def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : f...
547
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, D...
547
1
"""simple docstring""" from __future__ import annotations def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = None , __SCREAMING_SNAKE_CASE = None )-> Dict: if start is None: _SCREAMING_SNAKE_CASE : str = 0 if end is None: ...
338
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transform...
29
0
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin...
236
from __future__ import annotations from collections.abc import Callable def a__ ( a , a , a , a = 1_0_0 , ) -> float: A_ : Any = x_start A_ : int = fnc(a ) A_ : int = 0.0 for _ ...
236
1
import numpy as np import torch from ..models.clipseg import CLIPSegForImageSegmentation from ..utils import is_vision_available, requires_backends from .base import PipelineTool if is_vision_available(): from PIL import Image class lowerCAmelCase_ ( __A ): UpperCAmelCase__ ...
40
'''simple docstring''' import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def __UpperCamelCase ( *lowercase_ : Union[str, Any] ): """simple docstring""" if not isinstance(lowercase_ , lowercas...
536
0
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from...
701
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : Tuple = { """configuration_funnel""": ["""FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FunnelConfig"""], ...
235
0
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list[float] , UpperCamelCase__: list[float] ): SCREAMING_SNAKE_CASE__ = sorted(numsa + numsa ) SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = divmod(len(UpperC...
6
from datetime import datetime import matplotlib.pyplot as plt import torch def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" for param in module.parameters(): lowercase__ = False def _a ( ): """simple docstring""" lowercase__ = '''cuda''...
43
0
"""simple docstring""" from bisect import bisect from itertools import accumulate def snake_case ( A__ ,A__ ,A__ ,A__ ): UpperCAmelCase_ : Tuple = sorted(zip(__UpperCamelCase ,__UpperCamelCase ) ,key=lambda A__ : x[0] / x[1] ,reverse=__UpperCamelCase ) UpperCAmel...
711
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow lowerCamelCase_ = logging.getLogger() @unittest.skip('''Temporaril...
463
0
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logge...
562
def _lowerCamelCase ( __A : list[int] ) -> int: if not numbers: return 0 if not isinstance(__A , (list, tuple) ) or not all( isinstance(__A , __A ) for number in numbers ): raise ValueError('''numbers must be an iterable of intege...
485
0
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_avail...
716
'''simple docstring''' lowercase__ = 65_521 def __UpperCamelCase ( __lowerCamelCase : str ) -> int: '''simple docstring''' _a = 1 _a = 0 for plain_chr in plain_text: _a = (a + ord(__lowerCamelCase )) % MOD_ADLER ...
276
0
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.s...
392
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __a : def __lowercase ( self : Optional[Any] , SCREAMING_SNAKE_CASE : List[Any] ): '''simple docstri...
228
0
'''simple docstring''' import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import ...
357
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : str = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': [''...
357
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase : int = {'''configuration_encoder_decoder''': ['''EncoderDecoderConfig''']} try: if not is_torc...
367
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ......
367
1
"""simple docstring""" import os def snake_case (): '''simple docstring''' a : str = os.path.join(os.path.dirname(A_ ) , 'num.txt' ) with open(A_ ) as file_hand: return str(sum(int(A_ ) for line in file_hand ) )[:1_0] if __name__ == "__main__": ...
118
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def snake_case (A_ :int = 8 ): '''simple docstring''' a : Tuple = ascii_letters + digits + punctuation return ""....
118
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def __magic_name__ ( __a : str ): ...
513
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xope...
585
0
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokeniz...
634
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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 T...
634
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "t5-small": "https://huggingface.co/t5-small/resolve/main/config.json", "t5-base": "http...
604
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel _SCREAMING_SNAKE_CASE :...
400
0
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->int: """simple docstring""" if not numbers: return 0 if not isinstance(UpperCAmelCase , (list, tuple) ) or not all( isinstance(UpperCAmelCase , UpperCAmelCase ) for number in numbers ): ...
210
"""simple docstring""" from math import sqrt def UpperCamelCase ( UpperCAmelCase = 1_000_000 ) ->int: """simple docstring""" a_ = 0 a_ = 0 a_ = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , 2 *...
210
1
def _UpperCAmelCase ( a : int , a : int ): while second != 0: snake_case__ = first & second first ^= second snake_case__ = c << 1 return first if __name__ == "__main__": import doctest doctest.testmo...
654
"""simple docstring""" import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index,...
49
0
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): i...
269
from ..utils import DummyObject, requires_backends class __A ( metaclass=a ): __A = ["""torch"""] def __init__( self , *UpperCAmelCase_ , **UpperCAmelCase_ ): requires_backends(self , ["""torch"""] ) @classmethod def _snake_case ( cl...
269
1
def UpperCamelCase ( __magic_name__ : int ) -> int: """simple docstring""" lowercase__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def UpperCamelCase ( __magic_name__ : int ) -> int: """simple docstrin...
15
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determini...
22
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __UpperCAmelCase ( metaclass=_lowerCamelCase ): __lowercase = ["""note_seq"""] def __init__( self , *lowerCAmelCase_ , **lowerCAmelCase_ ): """simple docstring""" ...
542
'''simple docstring''' import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def SCREAMING_SNAKE_CASE__ ( __A , __A ) -> int: _snake_case = ar...
542
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_d...
160
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available snake_case__ : int = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ASTCon...
408
0
'''simple docstring''' def __snake_case (__UpperCAmelCase ): """simple docstring""" if len(__UpperCAmelCase ) <= 1: return lst lowerCamelCase_ : Dict = 1 while i < len(__UpperCAmelCase ): if lst[i - 1] <= lst[i]: i += 1 else: lowerCamelCase_ , ...
418
'''simple docstring''' import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def __snake_case (__UpperCAmelCase ): ...
418
1
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 .toke...
79
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
288
0
"""simple docstring""" def lowerCAmelCase_ ( lowercase_ : Dict , lowercase_ : Union[str, Any] , lowercase_ : Optional[Any] , lowercase_ : List[Any] ): '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0: i...
721
"""simple docstring""" import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSa...
401
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils i...
76
from __future__ import annotations from typing import TypedDict class lowercase_ ( __snake_case ): _lowerCamelCase = 42 _lowerCamelCase = 42 def snake_case (__lowercase ) -> list[str]: '''simple docstring''' if not isinstance(__lowercase , __...
670
0
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class A_ ( __lowerCamelCase ): '''simple docstring''' _UpperCamelCase : Union[str, Any] = CustomTokenizer pass
565
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_info() Up...
565
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusion...
347
'''simple docstring''' from ... import PretrainedConfig lowerCAmelCase__ : Dict = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class a ( SCREAMING_SNAKE_CASE ): """simple docstring""" ...
347
1
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of...
703
"""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 from trans...
183
0
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness _lowercase: Dict = '''\ @misc{chen2021evaluating, title={Evaluating Large Language Models...
192
def _lowerCamelCase ( snake_case = 10 ): if not isinstance(snake_case , snake_case ) or n < 0: raise ValueError('Invalid input' ) _lowerCAmelCase = 10**n _lowerCAmelCase = 28_433 * (pow(2 , 7_830_457 , snake_case )) + 1 return str(numbe...
192
1
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 lowercase ( _a ,_a ,_a ,_a ) -> Optional[int]: # Initialise PyTorch mod...
713
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import t...
306
0
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageR...
97
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def SCREAMING_SNA...
418
0
from __future__ import annotations from collections import Counter from random import random class lowerCamelCase : def __init__( self ) -> str: """simple docstring""" _snake_case : List[str] = {} def UpperCAmelCase_ ( self ...
708
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCamelCase (unittest.TestCase ): def UpperCAmelCase_ ( self ) ...
47
0
'''simple docstring''' from collections import defaultdict def UpperCAmelCase__ ( UpperCAmelCase_ : int ) -> int: __lowerCamelCase : Any = 1 __lowerCamelCase : Dict = True for v in tree[start]: if v not in ...
13
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not is_torch_available(): raise OptionalDe...
477
0
from __future__ import annotations SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } ...
52
from typing import Dict from .base import GenericTensor, Pipeline class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def _a ( self : Any , _snake_case : str=None , _snake_case : Dict=None , _snake_case...
52
1
"""simple docstring""" 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(...
231
import unittest import numpy as np from transformers import AlbertConfig, 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.numpy as j...
254
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class __snake_case( __A ): _A = ['''image_processor''', '''feature_extractor'''] _A = '''TvltImageProcessor''' _A = '''TvltFeatureExtractor''' def __init__( ...
718
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A__ ( UpperCamelCase__ ): '''simple docstring''' if ( (cp >= 0x4E00 and cp <= 0x...
168
0
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = 'T5Config' class snake_case_ ( a ):...
625
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_config...
625
1
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterM...
45
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transforme...
45
1
__A : Dict = "Alexander Joslin" import operator as op from .stack import Stack def __lowerCAmelCase( _SCREAMING_SNAKE_CASE ) -> int: """simple docstring""" _A = {'*': op.mul, '/': op.truediv, '+': op.add, '-': op.sub} ...
27
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_p...
193
0
from __future__ import annotations def lowerCAmelCase_ ( __UpperCAmelCase: int = 4 ) -> list[list[int]]: UpperCamelCase__ : Any = abs(__UpperCAmelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCAmelCase )] for y in range(__UpperCA...
369
from __future__ import annotations def lowerCAmelCase_ ( __UpperCAmelCase: str , __UpperCAmelCase: str ) -> bool: UpperCamelCase__ : List[str] = get_failure_array(__UpperCAmelCase ) # 2) Step through text searching for pattern UpperCam...
369
1
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCAmelCase_ ( __A ) -> tuple: ...
486
def lowerCAmelCase_ ( __A ) -> list: '''simple docstring''' for i in range(len(__A ) - 1, 0, -1 ): UpperCAmelCase__ = False for j in range(__A, 0, -1 ): if unsorted[j] < unsorted[j - 1]: ...
486
1
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin, SchedulerOutput @dataclas...
717
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_ti...
526
0
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def a__ ( _SC...
71
'''simple docstring''' from ..utils import DummyObject, requires_backends class _snake_case (metaclass=__SCREAMING_SNAKE_CASE): __A : Any =["speech"] def __init__( self ,*_snake_case ,**_snake_case ): requires_backends(self ,["speech"] ) class _s...
71
1
"""simple docstring""" # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version impo...
558
"""simple docstring""" import unittest import numpy as np from transformers import AlbertConfig, 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 ...
558
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : str = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See...
257
import numpy as np def UpperCamelCase ( _a , _a , _a , _a , _a ) -> List[Any]: '''simple docstring''' lowercase_ :Optional[Any] = int(np.ceil((x_end - xa) / h ) ) lowercase_ :List[str] = n...
257
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_UpperCAmelCase ) class lowercase__ ( _UpperCAmelCase ): a_ =field(default="""language-modeling""", metadata={"""includ...
721
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ....
115
0