code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : List[Any] = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } tr...
93
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
219
0
"""simple docstring""" def UpperCAmelCase ( a_, a_, a_, a_ ): '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: lowerCamelCase : List[Any] = mf_knapsack(i - 1, a_, a_, a_ ...
205
"""simple docstring""" 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 = { 'google/bigbird-roberta-base': 'https://hug...
205
1
"""simple docstring""" import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
153
"""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_util...
153
1
'''simple docstring''' 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 ...
368
'''simple docstring''' def lowercase__( __UpperCamelCase: list[list[float]] ): """simple docstring""" SCREAMING_SNAKE_CASE : list[list[float]] = [] for data in source_data: for i, el in enumerate(__UpperCamelCase ): ...
246
0
import inspect import unittest from transformers import BitConfig 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 BackboneTesterMixin from ...test_co...
330
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration a_ = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """weight"""), ...
330
1
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import...
361
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 UpperCAmelCase__ : Tuple = logging.get_logger(__name__) UpperCAmelCase__ : Union[str, ...
301
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() and is_transformers_version(">=", "4.25.0")): raise OptionalDe...
109
def __lowerCamelCase ( snake_case__ ) -> list: """simple docstring""" def merge(snake_case__ ,snake_case__ ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[...
306
0
import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version _snake_case : ...
358
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _snake_case : int = {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig...
179
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torc...
205
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common im...
205
1
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 ( TE...
238
from pathlib import Path import fire def lowerCamelCase__ ( snake_case_ : str , snake_case_ : str , snake_case_ : int ) -> str: __snake_case = Path(snake_case_ ) __snake_case = Path(snake_case_ ) dest_dir.mkdir(exist_ok...
238
1
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 __A =...
90
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers impor...
246
0
from itertools import permutations def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> bool: if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False lowerCamelCase__ : Dict = [7, 11, 13,...
360
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : int = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", ""...
45
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class a__ ( snake_case__ ): def __init__( self , _A , _A ): """simple docstring""" __lowerCAmelCase = params __lowerCAmelCase ...
92
"""simple docstring""" import os from distutils.util import strtobool def lowercase (_lowerCAmelCase , _lowerCAmelCase ): for e in env_keys: __lowerCAmelCase = int(os.environ.get(_lowerCAmelCase , -1 ) ) if val >= 0: return val ...
301
0
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def __lowerCAmelCase (__lowerCAmelCase ): # A local function to see if a dot lands in the circle. def is_in_circle(__lowerCAmelCase , __lowe...
322
'''simple docstring''' import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig...
322
1
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _a ( SCREAMING_SNAKE_CASE_ ...
92
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
179
0
def lowerCamelCase_ ( UpperCamelCase__ : int = 100_0000 ): '''simple docstring''' UpperCamelCase__ = limit + 1 UpperCamelCase__ = [0] * limit for first_term in range(1, UpperCamelCase__ ): for n in range(UpperCamelCase__, UpperCamelCas...
371
from __future__ import annotations from collections import Counter from random import random class __lowercase : '''simple docstring''' def __init__( self : List[Any] ): UpperCamelCase__ = {} def A_ ( self : ...
35
0
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIP...
238
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils....
238
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def SCREAMING_SNAKE_CASE__( ) -> tuple[list[int], int]: '''simple docstring''' UpperCamelCase__ = [randint(-10_00 , 10...
364
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__( _UpperCamelCase : list[int | str] ) -> None: '''simple docstring''' create_state_space_tree(_UpperCamelCase , [] , 0 , [0 for i in rang...
31
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, Pat...
256
"""simple docstring""" import numpy as np def lowercase ( lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : float ) -> np.ndarray: return np.where(vector > 0 , lowerCAmelCase__ , (alpha * (np.exp(lowerCAmelCase__ ) - 1)) ) if __name__ == "...
45
0
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCAmelCase__ ( *_a : str ): if not isinstance(a_ , a_ ): snake_case_ : Optional[int] = list(a_ ) for i in range(len(a_ ) ...
367
import numpy as np def lowerCAmelCase__ ( _a : np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
36
0
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) _a = logging.getLogger() def _a (...
322
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _a = '''.''' # Internal TensorFlow ops that can be s...
322
1
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") _snake_case = """https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) _snake_case = requests.get(url, he...
201
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 impor...
201
1
'''simple docstring''' from functools import reduce lowercase_ = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "6...
211
'''simple docstring''' import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(".") def __snake_case( _lowerCAmelCase ) -> int: snake_case__ : Optional[int] = ...
35
0
'''simple docstring''' import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCAmelCase = ...
184
'''simple docstring''' from PIL import Image def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ , lowerCAmelCase__ : Dict = image.size lowerCAmelCase__ : int = 0 lowerCAmelCase__ : int = imag...
184
1
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling_t...
13
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __SCREAMING_SNAKE_CASE : str = loggin...
31
0
'''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 x...
369
'''simple docstring''' from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowerCamelCase ( UpperCAmelCase__ : int ) -> int: lowercase_ : Any = prime_factors(UpperCAmelCase__ ) if is_square_free(UpperCAmelCase__ ...
21
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...im...
16
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
36
0
import inspect import unittest from transformers import BitConfig 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 BackboneTesterMixin f...
7
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __snake_case ( unittest.TestCase ): def lowerCamelCase ( self : Dict): """simple...
7
1
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor UpperCAmelCase_ = logging.get_logger(__name__) class lowercase__ ( __lowerCamelCase ): '''simple docstring''' def __init__( self, *__magic_name__, ...
201
from math import factorial def lowerCAmelCase_ ( __UpperCAmelCase: int , __UpperCAmelCase: int ) -> int: # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k <...
201
1
'''simple docstring''' import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config im...
61
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline ...
61
1
from __future__ import annotations def lowercase_ ( _A : str , _A : str ): """simple docstring""" lowerCamelCase__ : List[Any] = get_failure_array(_A ) # 2) Step through text searching for pattern lowerCamelCase__ , lowerCa...
184
from collections import defaultdict def lowercase_ ( _A : int ): """simple docstring""" lowerCamelCase__ : Union[str, Any] = 1 lowerCamelCase__ : Dict = True for v in tree[start]: if v not in visited: ret +=...
184
1
"""simple docstring""" 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, ) if is_sentencepiece_available(): from ..ta.to...
365
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve...
112
0
from __future__ import annotations import requests def lowerCAmelCase__ ( a__: Any ) -> dict: '''simple docstring''' _UpperCAmelCase = F'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty''' return requests.get(lowerCamelCase_ ).json() ...
329
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
21
0
"""simple docstring""" import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase...
298
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowerCAmelCase__ : def __init__( self : Optional[int] , ...
298
1
import inspect import unittest from transformers import BitConfig 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 BackboneTesterMixin from .....
7
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy,...
7
1
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' return "".join(sorted(lowerCamelCase_ ) ) def UpperCAmelCase__ (lowerCA...
356
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a__ : List[str] = { '''configuration_biogpt''': ['''BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BioGptConfig'''],...
195
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _a = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pas...
61
"""simple docstring""" def __a ( __lowerCamelCase ): UpperCAmelCase_ : List[str] = int(__lowerCamelCase ) if n_element < 1: UpperCAmelCase_ : List[Any] = ValueError("a should be a positive number" ) raise my_error UpperCAmelCase_ : List[An...
61
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset ...
46
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : List[str] = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_...
46
1
from statistics import mean, stdev def UpperCAmelCase__ ( _A : list , _A : int = 3 ): '''simple docstring''' a__ =min(_lowerCamelCase ) a__ =max(_lowerCamelCase ) # normalize data return [round((x - x_min) / (x_max - x_min) , _lowerCamelCase ...
188
'''simple docstring''' from __future__ import annotations def lowerCAmelCase_ ( _lowerCamelCase: list[int] ): if not nums: return 0 __SCREAMING_SNAKE_CASE : Optional[int] = nums[0] __SCREAMING_SNAKE_CASE : Union[str, Any] = 0 for num in nums[1:]: ...
112
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : List[Any] = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Fun...
70
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase : List[Any] = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Fun...
70
1
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(snake_case__ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('''doctest''').testmod(...
298
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): return "".join([hex(snake_case__ )[2:].zfill(2 ).upper() for byte in list(snake_case__ )] ) def __lowerCAmelCase ( snake_case__ ): # Check data validity, following RFC3548 ...
298
1
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __magic_name__ ( nn.Module): UpperCamelCase__ = 42 UpperCamelCase__ = 42 UpperCa...
21
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common ...
21
1
from __future__ import annotations def lowerCamelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : list[str] | None = None , UpperCamelCase__ : dict[str, float] | None = None , UpperCamelCase__ : bool = False , ) -> tuple[int...
90
from manim import * class A_ ( __lowerCamelCase ): '''simple docstring''' def SCREAMING_SNAKE_CASE__ ( self ): lowercase = Rectangle(height=0.5 , width=0.5 ) lowercase = Rectangle(height=0.25 , width=0.25 ) lowercase = R...
195
0
from ...processing_utils import ProcessorMixin class a_ ( lowerCamelCase ): lowercase = """WhisperFeatureExtractor""" lowercase = """WhisperTokenizer""" def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> ...
360
'''simple docstring''' import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE__ = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' SCREAMING_SNA...
183
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import ...
46
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' while b: lowerCAmelCase , lowerCAmelCase = b, a % b return a def UpperCAmel...
46
1
"""simple docstring""" import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerB...
366
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = (...
248
0
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HP...
70
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffuser...
70
1
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
358
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __snake_case = logging.get_logger(__nam...
219
0
import numpy as np import qiskit def UpperCamelCase_( lowerCamelCase_ = 8 , lowerCamelCase_ = None ) -> str: _lowercase : int = np.random.default_rng(seed=lowerCamelCase_ ) # Roughly 25% of the qubits will contribute to the key. # So we take more than we nee...
21
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, ...
21
1
"""simple docstring""" import math import sys def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : Tuple = '' try: with open(_UpperCamelCase , 'rb' ) as binary_file: __lowerCAmelCase : int = binary_file.read() for dat in data: __lowerCA...
182
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu,...
182
1
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging lowerCamelCase = log...
188
"""simple docstring""" import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem _SCREAMING_SNAKE_CASE : Any = importlib.util.find...
183
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import _LazyModule snake_case__ : str = {'tokenization_tapex': ['TapexTokenizer']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys snake_case__ : List[str] ...
367
"""simple docstring""" import os import pytest from transformers.dynamic_module_utils import get_imports snake_case__ : Optional[Any] = ''' import os ''' snake_case__ : Tuple = ''' def foo(): import os return False ''' snake_case__ : Any ...
314
0
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch_mi...
76
from __future__ import annotations def _UpperCAmelCase ( a__): '''simple docstring''' a_ : List[str] = str(a__) return len(a__) == 9 and set(a__) == set("""123456789""") def _UpperCAmelCase ( ): '''simple docstring''' for base_num in range(9_9_9_9 , 4_9...
248
0
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_device fro...
367
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy _lowerCamelCase = logging.get_...
67
0
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self , snake_case__ ): """simple docstring""" lowerCAmelCase : List...
108
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_...
219
0
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def _A ( SCREAMING_SNAKE_CASE : Optional[int] , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : Tuple ): """simple docstring""" a__ : List[Any] ={ "...
148
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) def _A ( SCREAMING_SNAKE_CASE :...
148
1
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def A ( _lowercase , _lowercase , _lowercase = 10**-10 ): SCREAMING_SNAKE_CASE : Tuple = a while True: SCREAMING_SNAKE_CASE ...
182
import itertools import string from collections.abc import Generator, Iterable def A ( _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : Union[str, Any] = iter(_lowercase ) while True: SCREAMING_SNAKE_CASE : Optional[Any] = tup...
182
1
"""simple docstring""" import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbo...
58
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..imag...
58
1
'''simple docstring''' import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import versi...
31
import numpy as np from PIL import Image def UpperCAmelCase_ ( _A , _A , _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = np.array(_A ) if arr.shape[0] != arr.shape[1]: raise ValueError('''The input array is not a square matrix''' ) SCR...
314
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 UpperCamelCase = logging...
334
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_availa...
334
1
def UpperCAmelCase ( a_ , a_ ) -> bool: """simple docstring""" __A = len(a_ ) __A = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by not taking any element # hence True/1 for i in ...
15
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase ={ "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json", } ...
67
0
import os import re 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 ...
10
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, id...
10
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __A = { "configuration_mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegaConfig", "MegaOnnxConfig"], } try: ...
148
"""simple docstring""" import sys from collections import defaultdict class lowerCamelCase__ : def __init__( self ): """simple docstring""" snake_case : Dict = [] def lowerCamelCase_ ( self , SCREAMING_SNAKE_CASE ):...
148
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_...
367
from string import ascii_uppercase _lowercase : str ={char: i for i, char in enumerate(ascii_uppercase)} _lowercase : Dict =dict(enumerate(ascii_uppercase)) def lowerCAmelCase_ ( _lowercase : str , _lowercase : str) -> str: ...
266
0
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : int ) ->int: _SCREAMING_SNAKE_CASE = [1] _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0, 0, 0 _SCREAMING_SNAKE_CASE = ugly_nums[ia] * 2 _S...
58
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """facebook/data2vec-text-base""": """http...
58
1
lowercase_ = """Tobias Carryer""" from time import time class _snake_case : def __init__( self : Optional[int], __lowercase : Dict, __lowercase : Optional[Any], __lowercase : Tuple, __lowercase : Optional[Any]=int(time() ) ): # noqa: B008 lowercase__ ...
355
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): lowercase__ = int(SCREAMING_SNAKE_CASE_ ) if decimal in (0, 1): # Exit cases for the recursion return str(SCREAMING_SNAKE_CASE_ ) lowercase__ , lowercase__ = divmod(SCREAMING_SNAKE_CASE_ , 2 ) retu...
224
0
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 _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ...
334
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetYaaag...
334
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "http...
230
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_spee...
230
1
import os import re 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 __A = logging.get_logger(__name__) __A = {"vocab_file": "spiece....
10
from typing import Any def lowerCAmelCase_ ( __a , __a , __a , __a , __a , ) -> list: """simple docstring""" _validation( __a , __a , __a , __a , __a , ) # Creates data structures and fill initial step lowerCamelCase__: dict ={}...
10
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
368
"""simple docstring""" from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
254
0
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available():...
32
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor lowercase_ = logging.get_logger(__name__) class snake_case ( _lowerCAmelCase ): '''simple docstring''' def __init__( self : Optional...
266
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( UpperCamelCase_ : Optional[Any], UpperCamelCase_ : str, UpperCamelCase_ : Tuple, UpperCamelCase_ : int, UpperCamelCase_ : Union[s...
359
"""simple docstring""" import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class _lowerCAmelCase ( lowercase ): """simple docstring""" def __init__( self : List[str], UpperCAmelCase__ ...
144
0
'''simple docstring''' import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor __lowerCAmelCase : List[Any] =logging.getLogger(__name__) __lowerCAm...
237
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def UpperCamelCase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str = "cpu" , lowerCAmelCase__ : Union[str, None] = None ) -> None: ...
224
0
"""simple docstring""" import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_atten...
355
"""simple docstring""" import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ....
68
0
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> Optional[Any]: """simple docstring""" assert x is not None assert y is not None snake_case__ : List[Any] = len(__lowerCAmelCase ) snake_case__ : Optional[Any] = le...
230
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...
230
1
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowerCAmelCase_ : Optional[int] = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMas...
346
'''simple docstring''' from manim import * class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" def UpperCamelCase__ ( self : Dict ): _a = Rectangle(height=0.5 , width=0.5 ) _a = Rectangle(height=0.46 ...
346
1
import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def lowerCAmelCase__( lowercase : List[Any] , lowercase : Any , lowercase : Any ) ...
326
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
254
0
from manim import * class lowercase_ ( __snake_case ): def UpperCamelCase ( self ): _snake_case : Dict = Rectangle(height=0.5 , width=0.5 ) _snake_case : Dict = Rectangle(height=0.46 , width=0.46 ).set_stroke(wid...
284
def snake_case (__lowercase ) -> list[int]: '''simple docstring''' if num <= 0: raise ValueError("Input must be a positive integer" ) _snake_case : Any = [True] * (num + 1) _snake_case : str = 2 while p * p <= num: i...
284
1
import os snake_case : Dict = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 1_00, '''D''': 5_00, '''M''': 10_00} def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" a :List[Any] = 0 a :Optiona...
94
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def _snake_case ( lowerCamelCase__ : T...
144
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow fr...
364
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _snake_case = False try: _snake_case = _is_package_available("goo...
300
0
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from .....
25
import copy import random from transformers import CLIPTokenizer class a__ ( snake_case ): """simple docstring""" def __init__( self , *lowercase , **lowercase ) -> Union[str, Any]: '''simple docstring''' super().__init__(*lowercase , **lowe...
68
0
'''simple docstring''' def UpperCAmelCase ( a_ = 4_0_0_0_0_0_0 ) -> int: """simple docstring""" A_ : List[Any] = [0, 1] A_ : List[Any] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] ...
164
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCAmelCa...
164
1
'''simple docstring''' import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": UpperCAmelCase_ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ...
346
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging UpperCAmelCase_ = '\\n\n' UpperCAmelCase_ = '\nPerplexity (PPL) is one of the most common me...
346
1
__UpperCamelCase : Optional[int] = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __A ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ...
347
def __A ( __lowerCamelCase ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
347
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipeline, UNeta...
284
# 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 app...
284
1
'''simple docstring''' def __magic_name__ ( A ) -> list[int]: snake_case = len(A ) for i in range(A ): for j in range(i + 1 , A ): if numbers[j] < numbers[i]: snake_case , snake_case = numbers[j], numbers[i] return numbers if __name__ == ...
332
'''simple docstring''' from __future__ import annotations from math import ceil, floor, sqrt def __magic_name__ ( A = 2_0_0_0_0_0_0 ) -> int: snake_case = [0] snake_case = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_numbe...
332
1
"""simple docstring""" import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP UpperCAmelCase__ : List[str]...
25
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ra...
300
0
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def __lowerCamelCase ( ): a__: Any =[randint(-1_000 , 1_000 ) for i in range(10 )] a__: List[str] =randint(-5_000 , 5_000 ) ...
42
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class lowerCamelCase__...
42
1
'''simple docstring''' from __future__ import annotations __A = [] def _A ( lowercase__ , lowercase__ , lowercase__ ): for i in range(len(lowercase__ ) ): if board[row][i] == 1: return False for i in range(len(lowercas...
164
'''simple docstring''' import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() __A = logging.get_logger(_...
164
1
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 from ...
141
from __future__ import annotations def UpperCamelCase (lowercase_: list[int] , lowercase_: list[int] , lowercase_: int ) -> tuple[float, list[float]]: A__ : Tuple = list(range(len(lowercase_ ) ) ) A__ : Union[str, Any] = [v / w for v, w in zip(lo...
141
1
"""simple docstring""" __SCREAMING_SNAKE_CASE : str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_S...
347
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't ...
347
1
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : def __init__( self :Tuple , lowercase_ :list[list[int]] )-> Union[str, Any]: A__ = TypeError( "Matrices must be formed from a list of zero or more lists containing at...
367
'''simple docstring''' import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from data...
123
0
"""simple docstring""" def lowercase__ ( snake_case_ :list[int] ): __UpperCAmelCase = len(snake_case_ ) for i in range(snake_case_ ): for j in range(i + 1 , snake_case_ ): if numbers[j] < numbers[i]: __UpperCAmelCase , __UpperCAmelCase = ...
332
"""simple docstring""" def lowercase__ ( snake_case_ :Union[str, Any] ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = max(snake_c...
332
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { '''BAAI/AltCLIP''': '''https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json''', # See all AltCLIP models at https:...
173
from __future__ import annotations from math import ceil, floor, sqrt def __lowercase ( _UpperCamelCase = 2000000 ) ->int: """simple docstring""" lowercase : list[int] = [0] lowercase : int for idx in range(1, ceil(sqrt(target * 2 ...
173
1
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_lowerCamelCa...
42
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
1
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optun...
352
import math class _a : def __init__( self : List[Any] , _SCREAMING_SNAKE_CASE : Any=0 )-> Optional[Any]: # a graph with Node 0,1,...,N-1 lowerCAmelCase__ : Optional[int] = n lowerCAmelCase__ : List[Any] = [ [math.inf fo...
211
0
'''simple docstring''' 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 im...
141
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmToken...
141
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, P...
188
"""simple docstring""" 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_ima...
188
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _lowerCamelCase : Optional[Any] = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ...
14
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import StableDi...
123
0
def UpperCamelCase ( snake_case__ : list , snake_case__ : int = 0 ) -> list: UpperCamelCase : List[str] = length or len(snake_case__ ) UpperCamelCase : List[str] = False for i in range(length - 1 ): if list_data[i] > list_data[...
103
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def UpperCamelCase ( snake_case__ : List[Any] , snake_case__ : Union[str, Any] , snake_case__ : Tuple , snake_case__ : Union[str, Any] , snake_case__ : List[Any]...
103
1