code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import 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 __a : Optional[Any] = logging.get_logger...
397
from math import factorial def snake_case_ ( SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) -> float: if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes...
397
1
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __snake_case :Dict = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
60
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteS...
60
1
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor lowerCamelCase__ : Union[str, Any] = logging.get_logger(__name__) class __magic_name__ (snake_case_ ): '''simple docstring''' def __init__( ...
33
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig lowercase = logging.getLogger(__name__) class lowercase__ ( A ): '''simple docstring''' _UpperCAmelCase = '''maske...
573
0
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 Decoder, DecoderOutput, Encoder, ...
706
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = { "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"], "feature_extraction_mctct": ["MCTCTFeatureExtractor"], "processing_mctct": ["MC...
202
0
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer lowerCAmelCase__ = logging.getLogger(__name__) def snake_case_ ( ): '''simple docstring''' _lowerCamelCase : ...
83
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
83
1
import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torc...
714
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ : str = { 'configuration_bigbird_pegasus': [ 'BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BigBirdPegasusConfig', 'BigBirdPegas...
166
0
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jn...
15
"""simple docstring""" def __lowercase ( snake_case_ : list ) ->float: '''simple docstring''' __A : Tuple = 0 while len(snake_case_ ) > 1: __A : List[Any] = 0 # Consider two files with minimum cost to be merged for _ in ran...
177
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A : str = R''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outpu...
720
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
141
0
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def A ( lowercase__ : list , lowercase__ : list , lowercase__ : list , lowercase__ : list , lowercase__ : list ) -> f...
45
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def A__ ( A : Dict , A : Any , A : Tuple , A : Tuple): '''simple docstring''' UpperCamelCase : Tuple = { "en": "Mac...
173
0
import sys def A ( __UpperCAmelCase ) -> str: '''simple docstring''' UpperCAmelCase_ = len(__UpperCAmelCase ) UpperCAmelCase_ = [[0 for x in range(__UpperCAmelCase )] for x in range(__UpperCAmelCase )] UpperCAmelCase_ = [[0 for x i...
561
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( '''kwargs, expected''' , [ ({'''num_shards''': 0, '''max_num_jobs''': 1}, []), ({'''num_shards''': 10, '''max_num_jobs''': 1}, [ra...
561
1
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytessera...
25
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 import ...
333
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _UpperCamelCase : Union[str, Any] = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwiftFormer...
710
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from...
341
0
'''simple docstring''' from typing import List from .keymap import KEYMAP, get_character def _a ( _lowerCamelCase ) -> int: """simple docstring""" def decorator(_lowerCamelCase ): __snake_case : str = getattr...
26
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_format, ) fr...
662
0
import requests def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> None: UpperCAmelCase_ = {"Content-Type": "application/json"} UpperCAmelCase_ = requests.post(__SCREAMING_SNAKE_CASE , json={"text": message_body} , headers=__SCREAMING_SNAKE...
23
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requi...
23
1
from PIL import Image def _A ( lowerCamelCase , lowerCamelCase ): def brightness(lowerCamelCase ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError("level must be between -255.0 (black) and 255.0 (white)" ) return img.point(lowerCamel...
112
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, O...
112
1
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSc...
709
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline a : List[str] = logging.get_logger(__name__)...
672
0
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast UpperCamelCase__ =datasets.utils.logging.get_logger(__name__) @dataclass class lowerCAmelCase__( dataset...
249
# 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 be considered # sinc...
249
1
from __future__ import annotations def a ( A__ , A__ = None ) -> list[list[str]]: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = word_bank or [] # create a table SCREAMING_SNAKE_CASE__ : int = len(A__ ) + 1 SCRE...
716
def a ( A__ , A__ , A__ ) -> float: '''simple docstring''' if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Exception('''Rate of interest must be >= 0''' ) if...
250
0
__a = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"""], } def _UpperCamelCase ( lowerCAmelCase_ , ...
377
def _UpperCamelCase ( lowerCAmelCase_ ) ->Any: UpperCAmelCase = 0 UpperCAmelCase = len(lowerCAmelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , lowerCAmelCase_ ): if arr[i] > arr[j]: num_inversions += 1 return num_invers...
377
1
"""simple docstring""" def _lowerCAmelCase ( _UpperCamelCase ): """simple docstring""" _lowercase: int = [0] * len(_UpperCamelCase ) _lowercase: int = [] _lowercase: Union[str, Any] = [] _lowercase: Union[str, Any] = 0 for values in...
716
"""simple docstring""" import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline A__ : List[Any] = datase...
272
0
'''simple docstring''' 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_availa...
502
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMi...
502
1
import logging from transformers.configuration_utils import PretrainedConfig UpperCAmelCase_ : List[Any] = logging.getLogger(__name__) class _SCREAMING_SNAKE_CASE ( _a ): snake_case__ : Dict = """masked_bert""" def __init__( self : List[str] , ...
711
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : list[int] ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) UpperCamelCase :List[Any] = sum(__magic_name__ ) / len(__magic_n...
590
0
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_availab...
656
'''simple docstring''' import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore _lowerCAmelCase :Any = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" _lowerCAmelCase :Any ...
251
0
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_com...
713
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
264
0
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils ...
43
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, D...
500
0
'''simple docstring''' import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowercase_ : List[str] = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operator.ge, ">": op...
719
'''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...
352
0
import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ) -> int: '''simple docstr...
481
from math import factorial _a = {str(digit): factorial(digit) for digit in range(10)} def lowerCAmelCase__(__snake_case ) -> int: '''simple docstring''' if not isinstance(__snake_case ,__snake_case ): raise TypeError('''Parameter number must be int''' ) if number <...
481
1
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __UpperCamelCase ( _A , _A=7 ): lowerCAmelCase_ = None if token is not None: lowerCAmelCase_ = {'''Accept''': '''application/vn...
325
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version _A = ...
325
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __a = logging.get_logger(__name__) __a = { 'shi-labs/nat-mini-in1k-224': 'https://huggingface.co/shi-l...
97
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tenso...
653
0
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin fro...
475
"""simple docstring""" import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __magic_n...
475
1
'''simple docstring''' from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
660
'''simple docstring''' from __future__ import annotations import math from collections.abc import Callable def lowerCamelCase__ ( A_ , A_ , A_ , A_ = 100 , ): UpperCAmelCase_ = x_start UpperCAmelCase_ = fnc(A_ ) UpperCA...
660
1
'''simple docstring''' from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from acce...
667
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: if num < 0: return False A_ = num A_ = 0 while num > 0: A_ = rev_num * 10 + (num % 10) num //= 10 return nu...
667
1
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def __lowerCAmelCase ( ) -> Union[str, Any]: """simple docstring""" snake_case : List[str] = ArgumentParser("Diffusers CLI tool" , usage="diffusers-cli <command> [<a...
178
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( snake_case_ ): __UpperCAmelCase : List[str] = (KDPMaDiscreteScheduler,) __Upp...
178
1
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. UpperCamelCase_ = 10 def _UpperCAmelCase ( A , A , A , ...
510
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-...
510
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : Optional[int] = logging.get_logger(__name__) __lowercase : Optional[Any] = { """studio-ousia/luke-base""": """https://huggingface.co/studio-ousia/l...
142
"""simple docstring""" __lowercase : Union[str, Any] = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Z...
142
1
'''simple docstring''' import argparse import os import re a_ = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict a_ = re.compile(r'''[A-Z_]+_MAPPING(\s+|_[A-Z_]+\s+)=\s+...
701
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = {'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Optional...
115
0
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class UpperCAmelCase_ ( __A , __A ): """simple docstring""" ...
94
'''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 fro...
236
0
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) from transforme...
313
import numpy as np def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): lowerCamelCase_ = int(np.ceil((x_end - xa) / h ) ) lowerCamelCase_ = np.zeros((n + 1,) ) lower...
313
1
"""simple docstring""" import numpy as np def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->str: """simple docstring""" lowerCAmelCase__ :int = int(np.ceil((x_end - xa) / h ) )...
93
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Any = { '''configuration_longformer...
653
0
import pickle import numpy as np from matplotlib import pyplot as plt class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ...
708
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, trans...
692
0
"""simple docstring""" from __future__ import annotations from typing import Any class _lowerCAmelCase ( snake_case_ ): pass class _lowerCAmelCase : def __init__( self , UpperCamelCase__ ) -> int: '''simple docstring''' snake_ca...
178
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { """microsoft/focalnet...
453
0
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py snake_case_ : int = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Met...
191
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 ...image_transforms import ( center_crop, get_re...
191
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time __lowercase : List[Any] =Lock() def a__ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ , ...
54
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
298
0
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from trans...
720
import csv import tweepy # Twitter API credentials lowerCamelCase :Optional[int] = '' lowerCamelCase :Tuple = '' lowerCamelCase :Tuple = '' lowerCamelCase :Optional[Any] = '' def __snake_case ( _UpperCamelCase ) -> None: # authorize twitter, initialize...
346
0
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property fro...
319
'''simple docstring''' import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_bytes=1337 , num...
22
0
'''simple docstring''' def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ): if height >= 1: move_tower(height - 1 , lowercase_ , lowercase_ , lowercase_ ) move_disk(lowercase_ , lowercase_ ) move_tower(height - 1 ...
720
'''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 A_ ( u...
695
0
'''simple docstring''' import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecode...
22
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_g...
539
0
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCamelCase (datasets.BeamBasedBuilder ): """simple docstring""" def A_ ...
718
from __future__ import annotations from collections.abc import Sequence from typing import Literal def _a ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : str ) -> str | Literal[False]: '''simple docstring''' SCREAM...
157
0
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": _UpperCAmelCase = input('Enter image url: ').strip() print(f'''Downloading image from {url} ...''') _UpperCAmelCase = BeautifulSoup(requests.get(url).content, 'html.parser')...
504
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Eff...
504
1
_UpperCAmelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_9344, "knot": 1.852, } _UpperCAmelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_7777_7778, "mph": 0.6_2137_1192, "knot": 0.5_3995_6803, } def UpperCamelCase ( lowercase...
702
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : List[str] = logging.get_logger(__name__) _UpperCAmelCase : str = { '''google/pix2struct-textcaps-base''': ( '''ht...
145
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor __magic_name__ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE_ ( snake_case_ ): """simple docstring""" def __init__( self , *lowerCAmelCase__ ...
155
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Optional[Any] = logging.get_logger(__name__) snake_case : str = {'v...
566
0
"""simple docstring""" import re import subprocess import sys __SCREAMING_SNAKE_CASE : Optional[Any] = subprocess.check_output("""git merge-base main HEAD""".split()).decode("""utf-8""") __SCREAMING_SNAKE_CASE : Tuple = subprocess.check_output(F"""git diff --name-only {fo...
700
"""simple docstring""" from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake __SCREAMING_SNAKE_CASE : List[str] = numpy.array([0, 0]) __SCREAMING_SNAKE_CASE : Optional[Any] = numpy.array([0.5, ...
623
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common ...
665
'''simple docstring''' import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import ...
665
1
"""simple docstring""" import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resi...
194
"""simple docstring""" import argparse import os import re import packaging.version __UpperCAmelCase = 'examples/' __UpperCAmelCase = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version...
194
1
from heapq import heappop, heappush import numpy as np def a ( A__ , A__ , A__ , A__ , ) -> tuple[float | int, list[tuple[int, int]]]: '''simple docstring''' SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : Union[str, Any] =...
35
"""simple docstring""" import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric fro...
259
0
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 ..image_utils import load_image if is_torch_a...
702
import fire from utils import calculate_rouge, save_json def _UpperCAmelCase ( UpperCamelCase: Any , UpperCamelCase: Union[str, Any] , UpperCamelCase: List[Any]=None , **UpperCamelCase: Optional[int] ): """simple docstring""" __lowerCAmelCase = ...
376
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case : Any = { '''configuration_squeezebert''': [ '''SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SqueezeBertConfig''...
53
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : Tuple = { '''kakaobrain...
149
0
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def __snake_case ( UpperCamelCase__ ) -> Any: """simple docstring""" if not is_accelerate_available(): return method ...
718
"""simple docstring""" import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase__ ( UpperCAmelCase_ , unittest.TestCase ): lowe...
91
0
'''simple docstring''' from sklearn.metrics import fa_score import datasets _UpperCAmelCase : Dict = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' _UpperCAmelCase : ...
107
"""simple docstring""" def lowercase__(A ) ->bool: """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
218
0
import doctest from collections import deque import numpy as np class UpperCAmelCase__ : """simple docstring""" def __init__( self : Optional[Any] ) -> None: SCREAMING_SNAKE_CASE__ = [2, 1, 2, -1] SCREAMING_SNAKE_CASE__ = [1, 2, 3, 4] def ...
472
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=A__ ) class UpperCAmelCase__ ( A__ ): """simple docstring""" a = field(default="question-answering-extractive" , m...
472
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase_ = {"tokenization_wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lowercase_ ...
11
'''simple docstring''' # Function to print upper half of diamond (pyramid) def _lowercase (SCREAMING_SNAKE_CASE ): '''simple docstring''' for i in range(0 , SCREAMING_SNAKE_CASE ): for _ in range(0 , n - i - 1 ): # printin...
111
0
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def a__ ( snake_case , snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : int = k_size // 2 __SCRE...
131
import math import random def a__ ( snake_case , snake_case = False ): """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowercase_ = 0.02 def a__ ( snake_case , snake_case ...
131
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acce...
315
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM...
315
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : List[str] = logging.get_logger(__name__) lowercase__ : Optional[int] = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json...
43
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase ( lowerCamelCase , unittest....
43
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.i...
172
'''simple docstring''' import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_...
172
1
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreTrain...
715
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ : List[Any] = logging.get_logger(__name__) lowercase_ : List[Any] = { 'facebook/xlm-roberta-xl': 'ht...
107
0
'''simple docstring''' import os import numpy import onnx def UpperCamelCase ( a , a ) -> List[Any]: '''simple docstring''' __magic_name__ = a.name __magic_name__ = b.name __magic_name__ = '''''' __magic_name__ = '''''...
432
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( __a ): __SCREAMING_SNAKE_CASE :Optional[int] = """ClapFeatureExtractor""" __SCREAMING_SNAKE_CASE :List[Any] = ("""Robe...
432
1
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device __lowerCamelCase : int = False class lowerCamelCase ( unittest.TestCase ...
501
import sys import turtle def lowercase__ ( __A: tuple[float, float] ,__A: tuple[float, float] ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase__ ( __A: tuple[float, float] ,__A: tuple[float, float] ,__A: tuple[...
501
1
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCamelCase__ ( unittest.TestCase ): """simple docstri...
104
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVeca...
372
0
from __future__ import annotations from cmath import sqrt def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if a == 0: raise ValueError("""Coeffici...
390
lowercase_ = "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_diffusion_version, is_librosa_available, is_note_s...
390
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentPars...
637
'''simple docstring''' from statistics import mean, stdev def a__ ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : int = 3 ) -> list: """simple docstring""" UpperCAmelCase_ : Dict = min(_SCREAMING_SNAKE_CASE ) UpperCAmelCase...
71
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'google/pix2struct-textcaps-base': ( 'https://huggingface.co/google/p...
701
"""simple docstring""" from math import sqrt def __lowercase ( lowerCamelCase_ : int ): SCREAMING_SNAKE_CASE__ = 0 for i in range(1 , int(sqrt(lowerCamelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCamelCase_ ): total += i + n // i ...
112
0
'''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_image_inputs if is_torch_av...
107
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __UpperCamelCase ( A__ ): __A : Dict ...
32
0
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowerCamelCase = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2col_cuda.cuh', 'models/...
707
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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity_info() lowerC...
303
0
def lowerCAmelCase_ ( __a ) -> bool: """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
59
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase_ ( __a ) -> float: """simple docstring""" return np.dot(__a , __a ) class _SCREAMING_SNAKE_CASE : '''simple docstring'''...
59
1
def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase , __lowerCAmelCase ): snake_case__ = word.split() def justify(__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> str: snake_case__ = max_width - width snake_case__ = len(A_ ) ...
710
import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available, ) from . import BaseTra...
530
0
"""simple docstring""" import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class __snake_case (__SCREAMING_SNAKE_CASE ): __a = """M-CLIP""" def __init__( self: Optional[int] , A_: Dict=10_24 , ...
281
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class A__ ( nn.Module): def __init__( self , __magic_name__ = 1_6 , __magic_name__ = 8_8 , __magic_name__ = None , __magic_name__ = 1 ...
681
0
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=_a ): """simple docstring""" __lowerCAmelCase : Optional[Any] =['''sentencepiece'''] def __init__( self :int, *snake_case :Union[str, Any], **snake_case ...
557
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class SCREAMING_SNAKE_CASE_ ( nn.Module ): """simple docstring""" __lowerCAmelCase : int ...
557
1
'''simple docstring''' import math import random def A (__lowerCamelCase :float , __lowerCamelCase :bool = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value _lowercase = 0.02 def A (__lowerCamelCase :int ...
5
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowercase ( unittest.TestCase ): def a ( self ): snake_case_ = 10 def a ...
362
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ : List[Any] = { 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfig'], ...
718
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union lowercase_ : str = re.compile(R'^(?P<major>\d+)' R'\.(?P<minor>\d+)' R'\.(?P<patch>\d+)$') @total_ordering @dataclass class _lowerCamelCase : ...
107
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = {} try: if not is_sentencepiec...
26
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
560
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel...
306
_lowerCAmelCase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _lowerCAmelCase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def lowercase ( _a ,_a ,_a ) -> list[int]: UpperCAmelCase_: Tuple = True UpperCAmelCase_: Optional[int] =...
306
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" @staticmethod @abstractmethod def _a ( _snake_case : ArgumentParser ): """simple docstring""" ...
9
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( '''files''' , [ ['''full:README.md''', '''dataset_infos.json'''], ['''empty:README....
674
0
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils impor...
712
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verb...
481
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Union[str, Any] = { "configuration_perceiver": ["PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP",...
429
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class __snake_case : lowerCAmelCase__ = 42 lowerCAmelCase__ = None ...
429
1
'''simple docstring''' import argparse import datetime def UpperCamelCase_ ( __SCREAMING_SNAKE_CASE ): """simple docstring""" snake_case_ : str = { "0": "Sunday", "1": "Monday", "2": "Tuesday", "3": "Wednesday", "4": "Thursday", ...
710
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # 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_ =...
92
0
"""simple docstring""" 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 ...
82
from string import ascii_uppercase __A = {str(ord(c) - 55): c for c in ascii_uppercase} def lowerCamelCase_ ( UpperCamelCase__ : int , UpperCamelCase__ : int ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ ...
469
0
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataColl...
267
'''simple docstring''' def UpperCAmelCase ( lowerCamelCase_ :str ): '''simple docstring''' return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() ...
267
1
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _a ( SCREAMING_SNAKE_CASE ): """simpl...
43
"""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_image_inputs if ...
554
0
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""): UpperCAmelCase_ : Optional[int] = { """linear""": PIL.Image.Resampling.BILINEAR, """bi...
440
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutp...
440
1
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_u...
457
'''simple docstring''' import collections import importlib.util import os import re from pathlib import Path lowerCAmelCase : List[str] = """src/transformers""" # Matches is_xxx_available() lowerCAmelCase : List[str] = re.compile(R"""is\_([a-z_]*)_available()""") # Catches a one...
372
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( ...
653
'''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 lowercase_ : Optional[Any] = logging.get_logger(__name__) lowercase...
653
1
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, ImagePipelineOutput ...
20
def _lowercase( __a : list[int] ): a__ =len(__a ) for i in range(__a ): for j in range(i + 1 , __a ): if numbers[j] < numbers[i]: a__ , a__ =numbers[j], numbers[i] return numbers ...
20
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtrac...
720
"""simple docstring""" import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_fu...
317
0
'''simple docstring''' class __A : def __init__( self , UpperCamelCase_ ): __UpperCAmelCase : Any = val __UpperCAmelCase : List[str] = None __UpperCAmelCase : str = None ...
168
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, re...
595
0
'''simple docstring''' from math import sqrt def __UpperCAmelCase ( A : int = 1_0_0_0_0_0_0 ) -> int: UpperCAmelCase_ : Dict = 0 UpperCAmelCase_ : List[Any] = 0 UpperCAmelCase_ : Optional[int] = 4_2 while num_cuboids <=...
712
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _UpperCamelCase : Optional[int] = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfi...
216
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenize...
79
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common im...
79
1
'''simple docstring''' import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( ...
714
'''simple docstring''' 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 UpperCamelCase ( lowercase_ : List[str] , lowercase_ : Optional[Any] , ...
145
0
from __future__ import annotations import math from collections.abc import Callable def lowercase ( __A : List[Any] , __A : Any , __A : Tuple , __A : Optional[Any] = 100 , ) -> float: '''simple docstring''' snake_case : Dict = x_start ...
36
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, ...
596
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling ...
161
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase_ = logging.get_logge...
161
1