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""" import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants __lowerCAmelCase : Any =Mapping[str, np.ndarray] __lowerCAmelCase : ...
197
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __magic_name__ ( __UpperCAmelCase ) -> str: '''simple docstring''' snake_case_ = [ '''encoder.version''', ...
56
0
UpperCamelCase = 256 # Modulus to hash a string UpperCamelCase = 100_0003 def _A ( lowerCAmelCase_ : str , lowerCAmelCase_ : str ): """simple docstring""" lowerCAmelCase__ = len(lowerCAmelCase_ ) lowerCA...
221
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder UpperCamelCase = '__DUMMY_TRANSFORMERS_USER__' UpperCamelCase = 'Dummy User' UpperCamelCase = 'hf_hZEmnoOEY...
221
1
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) fr...
45
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 a_ :Optional[Any] = logging.getLogger(__n...
277
0
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score f...
361
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE , unittest.TestCase ): '''simple do...
273
0
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 lowerCAmelCase__ : Union[str, Any] =False try: lowerCAm...
257
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def lowerCamelCase_ ( ): lowerCamelCase_ , lowerCamelCase_ = 9, 1_4 # noqa: F841 lowerCamelCase_ = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7...
19
0
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the roo...
224
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): lowercase__ = len(SCREAMING_SNAKE_CASE_ ) for i in range(SCREAMING_SNAKE_CASE_ ): for j in range(i + 1 , SCREAMING_SNAKE_CASE_ ): if numbers[j] < numbers[i]: lowercase__ , lowercase__ =...
224
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowercase = logging.get_logger(__name__) class _A ( ...
40
'''simple docstring''' import argparse import os import re __a = "src/transformers" # Pattern that looks at the indentation in a line. __a = re.compile(R"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. __a = re.compile(R"^\s*\"([^\"]+)\":") # Pattern that ...
35
0
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase_ : int = { """facebook/mask2former-swin-small-coco-instance""": ( """https://huggingface.co/facebook/ma...
197
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ : Dict = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is_torch_ava...
197
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compar...
110
def a__ ( _UpperCamelCase : int ): __lowerCamelCase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
330
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor UpperCAmelCase = logging.get_logger(__name__) class __magic_name__ ( __UpperCAmelCase ): def __init__( self : List[Any] , ...
172
"""simple docstring""" 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 UpperCAmelCase = '''\ @misc{chen2021evaluating, title={Evalu...
172
1
'''simple docstring''' def snake_case__ ( _A: int = 100 ) -> int: '''simple docstring''' lowerCAmelCase = n * (n + 1) * (2 * n + 1) / 6 lowerCAmelCase = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(f'{soluti...
272
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__( unittest.TestCase ): ...
272
1
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A ( __lowerCAmelCase , unittest.TestCase ): """simple docstring""" ...
357
import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis...
282
0
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transforme...
209
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A ( lowerCAmelCase ): '''simple docstring''' lowerCAmelCase_ = """Speech2TextFeatureExtractor""" lowerCAmelCase_ = """Speech2TextTokenizer...
209
1
"""simple docstring""" class _lowerCamelCase : def __init__( self : Union[str, Any] , UpperCamelCase : Dict ) -> Optional[int]: """simple docstring""" lowerCAmelCase__ : List[Any] = val lowerCAmelCase__ : Union[str, Any] = No...
212
"""simple docstring""" def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: return "\n".join( f"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_term...
212
1
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets __lowerCamelCase = "\\n@inproceedings{snover-etal-2006-study,\n title = \"A Study of Translation Edit Rate with Targeted Human Annotation\",\n author = \"Snover, Mat...
221
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json", } class U...
221
1
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class UpperCAmelCase : _lowercase: torch.Tensor # [batch_size x 3] _lowercase: torch.Tensor # [batch_size x 3] _low...
220
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch...
220
1
'''simple docstring''' import requests def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ) -> None: __lowerCamelCase = {'''Content-Type''': '''application/json'''} __lowerCamelCase = requests.post(UpperCamelCase__ , json={'''text''': message_body} , headers=UpperCa...
67
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch cl...
273
0
import math def lowerCamelCase__ (__lowerCamelCase ): assert isinstance(__lowerCamelCase, __lowerCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or n...
355
import numpy as np import datasets UpperCamelCase__ ='\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was introduced by Prof. P....
325
0
'''simple docstring''' import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.tes...
311
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosit...
311
1
from math import factorial def SCREAMING_SNAKE_CASE__ ( snake_case_ = 2_0 ) -> int: """simple docstring""" a = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... a = n // 2 return int(factorial(snake_...
330
from __future__ import annotations from collections.abc import Sequence from typing import Literal def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_ ) -> str | Literal[False]: """simple docstring""" a = list(snake_case_ ) a = lis...
330
1
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, ...
197
"""simple docstring""" from ..utils import DummyObject, requires_backends class _A ( metaclass=lowerCAmelCase ): snake_case__ : str = ['torch', 'transformers', 'onnx'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): ...
197
1
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( A__ , unittest.TestCase ): """s...
218
def UpperCAmelCase_ ( _A ): '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE__ = 1 SCREAMING_SNAKE_CASE__ = 1 while repunit: SCREAMING_SNAKE_CASE__ = (10 * repunit + 1) % divisor ...
218
1
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=lowercase ) class UpperCamelCase ( lowercase ): UpperCAmelCase ...
172
"""simple docstring""" import os import pytest from attr import dataclass _a : Optional[int]= "us-east-1" # defaults region @dataclass class UpperCamelCase : UpperCAmelCase : str UpperCAmelCase : Any = """arn:aws:iam::558105141721:role/sagemaker_exe...
172
1
"""simple docstring""" import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging lowerCAmelCase_ : Optional[int] =...
248
"""simple docstring""" from __future__ import annotations import numpy as np def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return np.maximum(0 , lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
248
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
243
"""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, ) UpperCamelCase_ = {'configuration_xgl...
243
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _UpperCamelCase: Dict = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable(...
53
"""simple docstring""" import unittest from transformers import DonutProcessor _UpperCamelCase: Any = 'naver-clova-ix/donut-base' class a__ ( unittest.TestCase ): def lowercase ( self : Optional[Any] ) -> Tuple: ...
53
1
def __lowerCAmelCase ( a__ ) -> int: # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __a = len(a__ ) __a = max(a__ ) __a = min(a__ ) # create the counting ...
6
from collections import defaultdict from math import gcd def _a ( UpperCamelCase_ : int = 1_500_000 ) -> int: """simple docstring""" lowerCAmelCase__ = defaultdict(UpperCamelCase_ ) lowerCAmelCase__ = 2 while 2 * euclid_m ...
340
0
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase = False ): """simple docstring""" if r...
184
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline 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 ..pipelin...
184
1
import random from typing import Any def UpperCamelCase_( lowerCamelCase_ ) -> list[Any]: for _ in range(len(lowerCamelCase_ ) ): _lowercase : Optional[int] = random.randint(0 , len(lowerCamelCase_ ) - 1 ) _lowercase : str = random...
21
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from transfo...
244
0
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def __A ( _lowercase , _lowercase , _lowercase ): '''simple docstring''' _A = TaConf...
354
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingf...
75
0
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.u...
309
import doctest from collections import deque import numpy as np class snake_case__ : def __init__( self ) -> None: __magic_name__ : Any = [2, 1, 2, -1] __magic_name__ : Tuple = [1, 2, 3, 4] def __magic_name__ ( self ) ...
342
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) UpperCamelCase__ : Dict = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.js...
358
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) UpperCamelCase__ : Dict = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.js...
330
0
from math import factorial def a__ ( _UpperCamelCase : int = 20 ): __lowerCamelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... __lowerCamelCase = n // 2 return int(factorial(_UpperCamelCase ) / (facto...
330
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ) from transformers.test...
330
1
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer UpperCAmelCase_ : List[str] = logging.get_logger(__name...
351
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start...
120
0
"""simple docstring""" import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowercase ( A_ )-> List[str]: '''simple docstring''' ...
40
'''simple docstring''' import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unord...
258
0
'''simple docstring''' def _UpperCAmelCase ( _UpperCamelCase : list ) -> list: def merge(_UpperCamelCase : list, _UpperCamelCase : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] ...
18
'''simple docstring''' from statistics import mean, stdev def _UpperCAmelCase ( _UpperCamelCase : list, _UpperCamelCase : int = 3 ) -> list: A_ = min(_UpperCamelCase ) A_ = max(_UpperCamelCase ) # normalize data ...
18
1
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _snake_case : List[str] = get...
292
from decimal import Decimal, getcontext from math import ceil, factorial def A ( lowercase ) -> str: '''simple docstring''' if not isinstance(lowercase , lowercase ): raise TypeError('Undefined for non-integers' ) elif precision < 1: raise ValueError('Undefined for non-natu...
222
0
"""simple docstring""" def a__ ( lowerCAmelCase ) -> bool: if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise ValueError("""check_bouncy() accepts only integer arguments""" ) UpperCAmelCase__ : Union[str, Any] = str(lowerCAmelCase ) UpperCAmelCase_...
166
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
166
1
'''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 snake_case ( unittest.TestCase ): """simple docstring""" def _low...
53
'''simple docstring''' from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Optional[int] , __A : list[list[int]] ): __UpperCamelCase = TypeError( 'Matrices must be formed from a list of ...
53
1
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" def __lowerCamelCase ( self ) -> Any: ...
361
from math import sqrt def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00_00_00 ): __UpperCamelCase : int = 0 __UpperCamelCase : int = 0 __UpperCamelCase : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_si...
171
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
184
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase__) class _lowercase ( lowercase__): """simple docstring""" A__ ...
184
1
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): _UpperCAmelCase : List[str] = (UnCLIPScheduler,) def __lowerCamelCase ( self : List[str] , **A...
265
from math import factorial class __SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , A : Dict , A : Any ) ->Optional[Any]: lowerCamelCase__ : Tuple = real if isinstance(A , A ): ...
265
1
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLI...
46
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints,...
75
0
from __future__ import annotations from collections.abc import Iterator class lowerCamelCase__ : '''simple docstring''' def __init__(self ,__lowerCamelCase ) -> None: """simple docstring""" lowerCAmelCase__ : Optional[Any] = value lower...
360
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase__ ( lowerCamelCase_ : ndarray): '''simple docstring''' return np.dot(lowerCamelCase_ ,lowerCamelCase_) class lowerCamelCase__ : '''simple docstri...
94
0
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : Tuple = args.pruning_method __magic_name__ :...
342
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __lowerCAmelCase ( lo...
330
0
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSeq...
360
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class lowerCamelCase ( nn.Module ): def __init__( self , SCREAMING_SNAKE_CASE_ = 16 , SCREAMING_SNAKE_CASE_ = 88 , SCRE...
27
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : Any ): # noqa: E741 '''simple docstring''' lowerCAmelCase : Optional[int] = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase : Any = 0 lowerCAmelCase : Optional[Any] ...
108
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() __A : Any ...
120
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ : Dict = logging.get_logger(__name__) A_ : List[st...
358
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class lowercase ( unittest.TestCase ): """simple docstring""" def _snake_case ( self ) -> Optional[Any]: _UpperCAmelCase : Any = [10, 20, 30, 40, 50, 60] ...
349
0
def _snake_case ( lowerCAmelCase : str , lowerCAmelCase : str = " " ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = [] SCREAMING_SNAKE_CASE_ : List[str] = 0 for index, char in enumerate(lowerCAmelCase ): if char == separator: ...
18
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ra...
18
1
'''simple docstring''' from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar a : Any = TypeVar("""T""") class UpperCamelCase_ ( Generic[T] ): lowercase = 42 # Cache store of keys lowercase = 42 ...
361
'''simple docstring''' a : Dict = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" def __lowerCamelCase ( ) -> None: UpperCAmelCase : Optional[int] = input("""Enter message: """ ) UpperCAmelCase : Dict = input("""Enter key [alphanumeric]: """ ) ...
338
0
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def _A ( _lowerCAmelCase ): """simple docstring""" if not sentence: return "" __lowercase =dict(zip(_lowerCAmelCase , _lowerCAmelCase ) ) return lower_...
166
'''simple docstring''' from typing import List import numpy as np def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase ={key: len(_lowerCAmelCase ) for key, value in gen_kwargs.items() if isinstance(_lowerCAmelCase , _lowerCAmelCase )} ...
166
1
import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.models.mbart.modeling_mbart impor...
367
import math def lowerCamelCase__ ( a__ : float , a__ : float ) -> float: if ( not isinstance(a__ , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("""power_factor must be a valid float...
261
0
from collections import deque from .hash_table import HashTable class snake_case_ ( __A ): '''simple docstring''' def __init__( self : int , *_UpperCamelCase : int , **_UpperCamelCase : Tuple ) ->Tuple: super().__init__(...
8
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _A = { """sample_size""": 32, """in_channels""": 3, """out_channels""": 3, """layers_per_block""": 2, """num_class_...
171
0
"""simple docstring""" from __future__ import annotations class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : Optional[Any] ,lowercase_ : Optional[Any] ,lowercase_ : List[str] ): lowerCAmelCase__ : Optional[Any...
367
"""simple docstring""" import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sq...
74
0
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.trai...
237
'''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.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controln...
237
1
'''simple docstring''' from math import isqrt, loga def _lowerCAmelCase ( lowercase ) -> list[int]: __lowerCAmelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , lowercase...
362
'''simple docstring''' import random def _lowerCAmelCase ( lowercase ) -> bool: __lowerCAmelCase = num - 1 __lowerCAmelCase = 0 while s % 2 == 0: __lowerCAmelCase = s // 2 t += 1 for _ in range(5 ): __lowerCAmelCase ...
46
0
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.ut...
8
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
94
0
import math def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :float , SCREAMING_SNAKE_CASE :float ) -> float: if ( not isinstance(SCREAMING_SNAKE_CASE , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("""power_factor must be a valid ...
232
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, ) import transformers from transformers...
232
1
from PIL import Image def _UpperCamelCase ( lowercase__ ): __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : Optional[Any] = image.size __SCREAMING_SNAKE_CASE : Optional[int] = 0 __SCREAMING_SNAKE_CASE : Optional[Any] = image.lo...
9
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowerCamelCase (_SCREAMING_SNAKE_CASE : int ): __a : int = int(number**0.5 ) return number == sq * sq def lowerCamelCase (_SCRE...
27
0
'''simple docstring''' import math from collections.abc import Callable def SCREAMING_SNAKE_CASE__( _UpperCamelCase : Callable[[float], float] , _UpperCamelCase : float , _UpperCamelCase : float ) -> float: '''simple docstring''' UpperCamelCase__ =...
356
'''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_...
31
0
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_...
3
'''simple docstring''' import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex a__ : Optional[Any] = logging.getLogger(__name__) class UpperCAmelCase__ : de...
349
0
'''simple docstring''' from __future__ import annotations def UpperCamelCase ( _lowerCamelCase : list , _lowerCamelCase : int , _lowerCamelCase : int , _lowerCamelCase : int ): A__ = [] A__, A__ = input_list[low:mid], input_list[mid : high + 1] w...
123
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils...
123
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class lowerCAmelCase__ ( a)...
11
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax if i...
338
0
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Optional[Any] = logging.get_logger(__name__) lowerCamelCase_ : Optional[int] = { "huggingface/informer-tourism-monthly": ( "ht...
370
def UpperCamelCase ( _A : int , _A : int )-> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def UpperCamelCase ( )-> None: """simple docstring""" assert and_gate(0 , 0 ) ...
198
0
def _a ( SCREAMING_SNAKE_CASE_ : list ): if any(not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(SCREAMING_SNAKE_CASE_ ...
92
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnP...
261
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, ...
313
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : lowercase__ = None lowercase__ = False lowercase__ = False lowercase__ ...
313
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except Opti...
82
"""simple docstring""" import argparse import struct import unittest class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Tuple ,A_ : bytes ) -> None: A = data # Initialize hash values A = [ ...
74
0
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutpu...
362
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 _UpperCAmel...
207
0
"""simple docstring""" __UpperCamelCase = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_di...
113
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWaterm...
46
0
"""simple docstring""" import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration _a = { 'tiny.en': 'https://openaipublic.azureedge.net/main/whisper/mode...
365
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _A ( ) -> Dict: '''simple docstring''' __lowercase = { "repo_name": ["test_repo1", "test_repo2", "test_...
144
0
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import Genera...
232
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class lowerCamelCase__ ( __lowercase): ...
232
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class _A ( metaclass=lowerCAmelCase ): snake_case__ : List[Any] = ['transformers', 'torch', 'note_seq'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ...
32
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __lowerCAmelCase : List[Any] ={ """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
32
1
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTester...
291
'''simple docstring''' import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_s...
31
0
'''simple docstring''' def __lowerCamelCase ( __lowerCAmelCase : int ) -> int: assert isinstance(_UpperCAmelCase , _UpperCAmelCase ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: ...
350
'''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.or...
3
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _snake_case : Optional[int] = { "configuration_distilbert": [ "DISTILBERT_PRETRAI...
123
from __future__ import annotations _snake_case : Any = "Muhammad Umer Farooq" _snake_case : Optional[int] = "MIT" _snake_case : Union[str, Any] = "1.0.0" _snake_case : Optional[Any] = "Muhammad Umer Farooq" _snake_case : List[Any] = "contact@muhammadu...
123
1
"""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 __SCREAMING_SNAKE_CASE ( __UpperCA...
357
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase: Tuple = logging.get_logger(__name__) UpperCAmelCase: List[Any] = { """CarlCochet/trajectory-transformer-halfcheetah-medium-v2""": ( """h...
336
0
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase_ ( a__ ): '''simple docstring''' a__ ...
88
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): lowercase__ : Optional[int] = 1 for i in range(1 , num + 1 ): fact *= i return fact def __UpperCamelCase ( UpperCAmelCase ): lowercase__ : Optional[Any] = 0 while number > 0: lowercase_...
198
0
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transf...
371
"""simple docstring""" import re from filelock import FileLock try: import nltk _a = True except (ImportError, ModuleNotFoundError): _a = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def _A ( UpperCamelCase_ ...
144
0
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter...
201
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTeste...
201
1
def UpperCAmelCase_ ( __lowerCamelCase : int ,__lowerCamelCase : int ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) lowercase_ :Dict = str(bin(A__ ) )[2:] # remove the leading "0b" lowercase_ :Unio...
357
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/license...
147
0
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class UpperCAmelCase_ ( unittest.TestCase ): def __magic_name__ ( self : Dict ) -> Tuple: '''simple docs...
247
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 ....
207
0
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def UpperCamelCase_ ( A__ : Sequence[float] , A__ : int , A__ : ...
362
'''simple docstring''' import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __A : List[str] = logging.get_logg...
89
0
"""simple docstring""" import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers...
150
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A__ : Tuple = {'configuration_reformer': ['REFORMER_PRETRAINED_CONFIG_...
144
0
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 VaeImageProcessor from diffusers....
306
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_available, is_vision_availa...
306
1
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class SCREAMING_SNAKE_CASE__ ( pl.LightningModule ): def __init__( self : List[str] , SCREAMING_SNAKE_CASE__ ...
32
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension...
32
1
'''simple docstring''' import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...
246
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { "configuration_mobilebert": [ "MOBI...
246
1
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, Im...
0
'''simple docstring''' class A : def __init__( self , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Tuple: """simple docstring""" A : Any = None A : Optio...
3
0
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_availa...
363
"""simple docstring""" import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_t...
112
0
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_...
322
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils imp...
300
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __UpperCamelCase ( a__ ): lowerCamelCase : str ="""Speech2TextFeatureExtractor""" lowerCamelCase : str ="""Spe...
79
"""simple docstring""" from datetime import datetime import requests def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->bytes: '''simple docstring''' a : Optional[Any] = "https://downloadgram.net/wp-json/wppress/video-downloader...
79
1
"""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 ...
249
"""simple docstring""" def _snake_case ( lowerCamelCase__ : str , lowerCamelCase__ : str , lowerCamelCase__ : List[Any] , lowerCamelCase__ : str ) -> str: global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: ...
144
0
"""simple docstring""" from math import factorial def _A ( lowercase , lowercase , lowercase ): """simple docstring""" if successes > trials: raise ValueError('''successes must be lower or equal to trials''' ) if trials < 0 or successes < 0: ...
215
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCamelCase_ : Union[str,...
215
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTokenizerFast, ...
26
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, ra...
147
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'SCUT-DLVCLab/lilt-roberta-en-base': ( 'https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json' ), } clas...
356
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_...
328
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer a : List[Any] = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"...
311
'''simple docstring''' from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def __lowerCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> np.ndarray: _a : Un...
89
0
"""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 SCREAMING...
74
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __UpperCamelCase : Union[str, Any] = namedtuple( ...
74
1
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ,snake_case__ ) -> Tuple: """simple docstring""" _S...
306
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils im...
306
1
import pickle import numpy as np from matplotlib import pyplot as plt class lowercase_ : def __init__( self , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase=0.2 , __UpperCamelCase=0.2 ):...
365
from __future__ import annotations def lowerCamelCase__ ( a__ : list[list[int]] ) -> int: # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in...
261
0
import copy import random from transformers import CLIPTokenizer class __magic_name__ ( lowerCamelCase__ ): """simple docstring""" def __init__( self :Optional[Any] , *snake_case :str , **snake_case :Optional[int] ): '''simple docstr...
300
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _lowerCAmelCase : int = '''\ @misc{wu2016googles, title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author=...
300
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_featur...
368
"""simple docstring""" import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('dataset_size' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('input_in_memory_max_size' , ['default', 0, 100 * 2**20, 900 * 2**20] ) def __lowerCAme...
182
0