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
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels lowerCAmelCase__ = object() # For specifying empty leaf dict `{}` lowerCAmelCase__ = object() def _UpperCAmelCase (Upp...
11
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thin...
11
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_tens...
362
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import Onn...
194
0
'''simple docstring''' import math def _a( ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[Any] =input('''Enter message: ''' ) SCREAMING_SNAKE_CASE__ : List[str] =int(input(f"Enter key [2-{len(Upp...
152
'''simple docstring''' import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def _a( UpperCamelCase__ : List[Any] ): '''simple docstri...
152
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_available, is_to...
352
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test...
121
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { """roberta-base""": """https://huggin...
325
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 AudioPipelineOutput, B...
325
1
"""simple docstring""" def lowerCAmelCase_ ( __A, __A ) -> Optional[Any]: '''simple docstring''' UpperCAmelCase__ = [0 for i in range(r + 1 )] # nc0 = 1 UpperCAmelCase__ = 1 for i in range(1, n + 1 ): ...
353
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer UpperCamelCase__ = logging.getLogger(__name__) def lowerCAmelCase_ ( ) -> Union[str, Any]: '''simple docstring''' U...
143
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity...
78
"""simple docstring""" class A_ : """simple docstring""" def __init__( self :List[Any] , lowercase_ :int ) -> None: UpperCAmelCase = size UpperCAmelCase = [0] * size UpperCAmelCase ...
78
1
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # se...
22
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.utils import log...
22
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase = { """co...
173
"""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`""")
241
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_to...
365
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case = { '''configuration_trajectory_transformer''': [ '''TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TrajectoryTransformerConfig''', ...
342
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, ImagePipelineOutput s...
281
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem from .utils import require_lza, require_zsta...
281
1
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken l...
354
from collections import namedtuple import requests from lxml import html # type: ignore lowercase_ = namedtuple("""covid_data""", """cases deaths recovered""") def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ = "https://www.worldometers.info/coronavirus/" ): lowercase__ = "//div[@...
224
0
def _A ( SCREAMING_SNAKE_CASE : Any ): """simple docstring""" a__ : Any =[0] * len(SCREAMING_SNAKE_CASE ) a__ : List[Any] =[] a__ : Dict =[1] * len(SCREAMING_SNAKE_CASE ) for values in graph.values(): ...
95
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) class __A (snake_case__): '''simple docstring''' def __init__( self : ...
347
0
"""simple docstring""" import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef a__ : Optional[Any] = ( '''This metric will be...
195
"""simple docstring""" import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) def UpperCAmelCase__ (lowerCAmelCase_ ...
195
1
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : List[str] ): '''simple docstring''' lowerCAmelCase = [] lowerCAmelCase = set({"""(""", """[""", """{"""} ) lowerCAmelCase = set({""")""", """]"...
46
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' while b: lowerCAmelCase , lowerCAmelCase = b, a % b return a def UpperCAmel...
46
1
"""simple docstring""" def UpperCAmelCase ( a_ ): '''simple docstring''' lowerCamelCase : Optional[int] = generate_pascal_triangle(_lowerCamelCase ) for row_idx in range(_lowerCamelCase ): # Print left spaces for _ in range(num_rows - row_idx -...
363
"""simple docstring""" def UpperCAmelCase ( a_, a_ ): '''simple docstring''' while b: lowerCamelCase , lowerCamelCase : Tuple = b, a % b return a def UpperCAmelCase ( a_, a_ ): '''simple docstring''' return a if b ...
205
0
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase ( UpperCAmelCase__ : Optional[int] , UpperCAmelCase__ : ...
239
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list ) -> list: if any(not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in ...
239
1
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformer...
369
'''simple docstring''' import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __S...
346
0
"""simple docstring""" # 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 model through reduction of a normal pre-trained model, but keeping the # ...
144
"""simple docstring""" from sklearn.metrics import fa_score import datasets A__ : List[str] = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' A__ : List[Any] = ...
144
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch if is_vision_ava...
300
_snake_case = 8.3144598 def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("Molar mass cannot be less than ...
300
1
'''simple docstring''' import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...
47
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ): @property def ...
278
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_...
211
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch...
211
1
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def A__ ( UpperCAmelCase_ ): return x + 2 class lowercase__ ( unittest.TestCase ): def UpperCamelCase_ ( self ...
83
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase__ : Union[str, Any] = TypeVar('T') class UpperCAmelCase ( Generic[T] ): '''simple docstring''' __UpperCamelCase : deque[T] # Cache store of ke...
121
0
'''simple docstring''' from collections import deque class A_ : '''simple docstring''' def __init__( self : Any , lowercase_ : str , lowercase_ : int , lowercase_ : int ) -> None: UpperCAmelCase : Op...
280
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowercase__ = TypeVar("KEY") lowercase__ = TypeVar("VAL") @dataclass(frozen=_snake_case , slots=_snake_case ) cla...
280
1
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, ...
259
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, require_vision from transformers.uti...
259
1
'''simple docstring''' import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transfo...
356
'''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 _lowercase : List[Any] = logging.get_logger(__nam...
264
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :int = logging.get_logger(__name__) class A_ ( lowerCAmelCase_ ): _lowerCamelCase : Tuple = """encoder-decoder""" _lowerCame...
22
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default...
22
1
"""simple docstring""" import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib _lowerCAmelCase :Unio...
367
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class _UpperCAmelCase : '''simple docstring''' def __init__( self ) -> Tuple: _UpperCAmelCase : str = {} def __lo...
68
0
'''simple docstring''' import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig...
79
from __future__ import annotations from PIL import Image # Define glider example A : Any = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0...
274
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, Effi...
360
import os def UpperCamelCase_( _snake_case : str = "input.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(_snake_case ) , _snake_case ) ) as input_file: __a =[ [int(_snake_case ) for element i...
308
0
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_...
278
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_available(): f...
278
1
def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int): while a != 0: lowercase__ : Dict = b % a, a return b def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int): if gcd(_lowerCamelCase , _lowerCame...
355
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def lowercase_ ( _lowerCamelCase : List[str]): return 1 / (1 + np.exp(-z)) def lowercase_ ...
333
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __A : int = logging.get_logger(__name__) __A : str = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT MSN models at htt...
138
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proces...
138
1
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class A ( enum.Enum ): __snake_case ...
167
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A = { '''configuration_rembert''': ['''REMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP'...
167
1
import unittest import numpy as np from transformers import RoFormerConfig, 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 jnp fro...
13
'''simple docstring''' import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageCl...
152
0
"""simple docstring""" from itertools import count def __a ( _SCREAMING_SNAKE_CASE = 50 ) ->int: a__: Optional[Any] = [1] * min_block_length for n in count(_SCREAMING_SNAKE_CASE ): fill_count_functions.append(1 ) for block_length in range(_S...
203
"""simple docstring""" import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.util...
203
1
'''simple docstring''' import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common imp...
229
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.uti...
229
1
"""simple docstring""" from __future__ import annotations def _A ( UpperCamelCase_ : str, UpperCamelCase_ : list[str] | None = None, UpperCamelCase_ : dict[str, float] | None = None, UpperCamelCase_ : bool = False, ) -> tuple[int, float, str]: '''simple doc...
370
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers im...
144
0
import fire from utils import calculate_rouge, save_json def UpperCamelCase( __UpperCamelCase : Optional[Any] ,__UpperCamelCase : Tuple ,__UpperCamelCase : int=None ,**__UpperCamelCase : str ): lowerCAmelCase_ : str = [x.strip() for x in open(__UpperCam...
103
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A__ : Optional[Any] = { '''facebook/mask2former-swin-small-coco-instance''': ( '''https://huggingface.co/facebook/mask2fo...
103
1
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common im...
361
'''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 ModelT...
294
0
'''simple docstring''' 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 ): """simple docstring""" def lowerCAmelCase__ ( self ): '''simple ...
97
"""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
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 _lowerCamelCase( a , a , a ): if not arr: return None, None, 0 if low == high: ...
371
"""simple docstring""" import os def _lowerCamelCase( ): with open(os.path.dirname(a ) + "/grid.txt" ) as f: __a = [] # noqa: E741 for _ in range(2_0 ): l.append([int(a ) for x in f.readline().split()] ) ...
268
0
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_available f...
231
"""simple docstring""" import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Toke...
269
0
'''simple docstring''' from __future__ import annotations from math import pow, sqrt def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ): if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if re...
214
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): def merge(UpperCAmelCase , UpperCAmelCase ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yield from right return list(_merge() ) ...
214
1
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): ...
56
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
262
0
'''simple docstring''' import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, D...
179
'''simple docstring''' import argparse from collections import defaultdict import yaml _snake_case : int = 'docs/source/en/_toctree.yml' def snake_case_ (UpperCamelCase : Optional[int] ): '''simple docstring''' _a = defaultdi...
179
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_: Optional[Any] =logging.get_logger(__name__) SCREAMING_SNAKE_CASE_: List[Any]...
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __a = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltCLIPTextConfig...
66
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor a :str = logging.get_logger(__name__) class __a (UpperCamelCase_): '''simple docstring''' def __init__( self , *_a , **_a ) ->...
370
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import...
56
0
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCAmelCase__ = input('''Enter image url: ''').strip() print(F"""Downloading image from {url} ...""") lowerCAmelCase__ = BeautifulSoup(requests.get(ur...
72
'''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 lowerCamelCase :Tuple = logging.get_logger(__name...
206
0
_UpperCAmelCase = 256 # Modulus to hash a string _UpperCAmelCase = 1_000_003 def UpperCamelCase ( snake_case__ : Tuple , snake_case__ : Tuple ) -> Optional[Any]: UpperCamelCase : int = len(_A ) UpperCamelCase : Union[str, Any] = ...
353
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowerCAmelCase_ ( a__ ): def __init__( self, SCREAMING_SNAKE_CASE_, ...
103
0
import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { 'facebook/data2vec-base-960h': 'https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json', # See all Dat...
178
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: UpperCAmelCase : Optional[Any] = None try: import msvcrt except ImportError: UpperCAmelCase : List[Any] = None try: import fcntl except ImportError: Up...
267
0
def _lowercase ( UpperCamelCase_ ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE__ = 0 for ch in input_str: SCREAMING_SNAKE_CASE__ = ord(A__ ) SCREAMING_SNAKE_CASE__ = pow(2 , A__ ) # If ...
351
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __snake_case = logging.get_logger(__name__) __snake_case = {name: getattr(transformers, name + """Fast""") for name in SLOW_TO...
169
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() lowercase__ =logging.get_logger(__name__) lowercase__ =[ ['attention', 'attn'], ['encoder_attention', 'encoder_attn'], ...
216
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter lowercase__ =True except ImportE...
216
1
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCamelCase__ ( __snake_case, __snake_case=False ) -> List[str]: """simple docstring""" _UpperCamel...
100
"""simple docstring""" class _UpperCAmelCase: def __init__( self , __a , __a , __a) -> List[Any]: '''simple docstring''' _UpperCamelCase = name _UpperCamelCase = value _UpperCamelCase = weight def __r...
100
1
def lowercase_ (A : Optional[int] ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: ...
277
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline a_ :List[Any] = logging.get_logger(__name__) @a...
277
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer _SCREAMING_SNAKE_CASE = {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''t...
354
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Fo...
217
0
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( UpperCAmelCase_ : list[int] ) -> int: '''simple docstring''' __snake_case : str = len(UpperCAmelCase_ ) // 2 # choose the middle 3 elements __snake_case : ...
172
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import loggin...
172
1
"""simple docstring""" import heapq import sys import numpy as np A : Optional[Any] = tuple[int, int] class _UpperCamelCase : '''simple docstring''' def __init__( self ): __lowerCAmelCase = [] __lowerCAmelCase = set(...
360
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def _lowerCamelCase ( ): '''simple docstring''' __lowerCAmelCase = {} __lowerCAmelCase = 2 while True: __lowerCAmelCase = factor_map.pop(_UpperCamelCase ...
259
0
"""simple docstring""" def lowercase_ ( _snake_case = 200 ): SCREAMING_SNAKE_CASE__ : List[str] = [1, 2, 5, 10, 20, 50, 100, 200] SCREAMING_SNAKE_CASE__ : Any = [0] * (pence + 1) SCREAMING_SNAKE_CASE__ : Tuple ...
25
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 10**9 ): __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE = 2 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 while perimeter <= max_p...
100
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaI...
367
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> float: if principal <= 0: raise Exception("""Principal borrowed must be > 0""" ) if rate_per_annum < 0: raise Exception("""Rate of interest mus...
56
0
"""simple docstring""" from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import Ten...
269
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __snake_case : Optional[int] = logging.get_logger(__name__) class...
269
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
210
def UpperCAmelCase_ ( __UpperCAmelCase : str ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__UpperCAmelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('doctest').testmod()
210
1
'''simple docstring''' from collections.abc import Callable class __lowercase : def __init__(self , A = None ): # Stores actual heap items. lowerCamelCase_ : list = [] # Stores indexes of each item for supporting updates and deletion. lowerCamelCase_ :...
318
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, Aut...
318
1
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): if discount_rate < 0: raise ValueError("Discount rate cannot be negative" ) if not cash_flows: raise ValueError("Cash flows list cannot be empty" ) lowercase :str = sum( cash_flow / ((1 + discount_rate) ** ...
357
from collections.abc import Iterable from typing import Generic, TypeVar _UpperCAmelCase : Any = TypeVar("_T") class __lowerCAmelCase ( Generic[_T]): def __init__( self: Union[str, Any] , _lowerCAmelCase: Iterable[_T] | None = None ): lowercase ...
158
0
"""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 a_ = get_tests_dir("""fixtures/spiece.mod...
179
"""simple docstring""" 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_util...
179
1
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _snake_case = logging.get_logger(__name__) _snake_case = { '''post_extract_proj''': '''feature_projection.pro...
342
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _snake_case = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'''), ('''kernel''', ...
342
1
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb ...
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
"""simple docstring""" import math def __lowerCAmelCase (_UpperCamelCase ): return math.sqrt(_UpperCamelCase ) * math.sqrt(_UpperCamelCase ) == num def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : int = 0 __lowerCAmelCase : List[Any] = ...
182
"""simple docstring""" class A__ : def __init__( self , _SCREAMING_SNAKE_CASE ): __lowerCAmelCase : List[Any] = size __lowerCAmelCase : str = [0] * size __lowerCAmelCase : Any = [0] * size @staticmethod def ...
182
1
"""simple docstring""" from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __lowercase ( snake_case_ : Sequence[float] ,snake_case_ : int ,snake_case_ : int ) ->tuple[int | No...
179
"""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 from...
179
1
def __magic_name__ ( __lowerCAmelCase : int = 50 ) -> int: __lowerCamelCase = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_leng...
359
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Tuple = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config....
339
0
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils...
194
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 .tokenization_b...
170
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 AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ : str = logging.get_log...
361
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image...
170
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : Optional[Any] =logging.get_logger(__name__) __lowerCAmelCa...
197
'''simple docstring''' 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 c...
168
0
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __snake_case ( __UpperCamelCase : Union[str, Any] ): """simple docstring""" A_ = [ "encoder.version", ...
362
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGE...
329
0
'''simple docstring''' import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_availab...
223
'''simple docstring''' lowerCAmelCase : Optional[int] =256 # Modulus to hash a string lowerCAmelCase : Tuple =1_000_003 def UpperCAmelCase_ ( __lowerCamelCase : str ,__lowerCamelCase : str ): lowercase_ :Dict = len(__lowe...
223
1
"""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_con...
38
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase = logging.get_logger(__name__) def lowercase (SCREAMING_SNAKE_C...
38
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer snake_case_ : Dict = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer....
83
def _A ( ): for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def _A ( SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase :Optional[int] = 1 UpperCamelCase :List[Any] = 2 while i * i <= n: UpperCamelCase :str ...
259
0
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] ...
358
import logging import os from .state import PartialState class lowercase ( logging.LoggerAdapter ): @staticmethod def __UpperCamelCase ( A_ ) -> Optional[Any]: """simple docstring""" UpperCamelCase = PartialState() return not main_process_only or (main_process_only an...
110
0
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers...
37
'''simple docstring''' import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig fr...
56
0
"""simple docstring""" import os from pathlib import Path def __lowerCamelCase ( ) -> List[str]: from torch.utils.cpp_extension import load __SCREAMING_SNAKE_CASE :List[str] = Path(a_ ).resolve().parent.parent.parent / '''kernels''' / '''de...
239
"""simple docstring""" from torch import nn class _SCREAMING_SNAKE_CASE( nn.Module ): def __init__( self ,SCREAMING_SNAKE_CASE__ ,SCREAMING_SNAKE_CASE__ ) -> List[str]: """simple docstring""" super()...
239
1
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> Dict: # Initialise PyT...
48
import warnings 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 __SCREAMING_SNAKE_CASE( a_ ...
307
0
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import write_b...
327
from scipy.stats import pearsonr import datasets a_ : Optional[int] = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption t...
327
1
import socket def A_ ( ) -> List[str]: a__ : Any = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) a__ : Dict = socket.gethostname() a__ : List[str] = 1_2312 sock.connect((host, port) ) sock.send(B'Hello server!' ) with o...
99
"""simple docstring""" from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __UpperCamelCase = 0 __UpperCamelCase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], ...
69
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
359
'''simple docstring''' def _A ( A__ ): """simple docstring""" stooge(A__ , 0 , len(A__ ) - 1 ) return arr def _A ( A__ , A__ , A__ ): """simple docstring""" if i >= h: return # If first element is smaller than the last then swa...
52
0
from typing import TYPE_CHECKING from ...utils import _LazyModule A__ = {"""tokenization_bertweet""": ["""BertweetTokenizer"""]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys A__ = _LazyModule(__name__, globals()["""__file__"""], _import_st...
82
"""simple docstring""" import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __Upper...
113
0
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase ( snake_case_ ): _lowercase: Tuple = ['''image_processor''', '''tokenizer'''] _lowerc...
364
'''simple docstring''' import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnles...
220
0
A_ : Optional[Any] = 6_5521 def UpperCamelCase (lowercase_: str ) -> int: A__ : str = 1 A__ : List[Any] = 0 for plain_chr in plain_text: A__ : Union[str, Any] = (a + ord(lowercase_ )) % MOD_ADLER A__ : Optio...
192
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def UpperCamelCase (lowercase_: str ) -> Dict: A__ : int = int(lowercase_ ) A__ , ...
192
1
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class __lowercase : """simple docstring""" pass
354
def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = [] lowerCamelCase = 1 while len(lowerCamelCase__ ) < 1E6: constant.append(str(lowerCamelCase__ ) ) i += 1 lowerCamelCase = """""".join(lowerCamelCase__ ...
66
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase : Dict = { '''kssteven/i...
300
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets _lowerCAmelCase : List[Any] = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "Snover, Matthew and Dorr,...
300
1
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a_ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, ...
364
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def a__ ( __lowerca...
163
0
"""simple docstring""" from math import factorial, radians def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase = 18 , _UpperCamelCase = 10 ): __lowerCAmelCase : List[Any] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radi...
86
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Conf...
86
1
def _UpperCAmelCase (UpperCamelCase_ : int , UpperCamelCase_ : float , UpperCamelCase_ : float ): '''simple docstring''' return round(float(moles / volume ) * nfactor ) def _UpperCAmelCase (UpperCamelCase_ : float , UpperCamelCase_ : float , UpperCamel...
159
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _lowerCamelCase : str = "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenag...
159
1
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_trajectory_transformer''': [ '''TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Traj...
108
def A_ ( a ): """simple docstring""" return "".join(chr(ord(a ) - 3_2 ) if 'a' <= char <= 'z' else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
253
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : Optional[Any] = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Autofor...
284
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require_sent...
284
1
from collections import deque from .hash_table import HashTable class _SCREAMING_SNAKE_CASE ( _a ): def __init__( self : Union[str, Any] , *__lowerCamelCase : Dict , **__lowerCamelCase : str ): super().__init__(*__lowerCamelCase , **__lowerCamelCase ) def...
38
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : list[list[int]] , __magic_name__ : int , __magic_name__ : int , __magic_name__ : list[int] ) -> bool: """simple docstring""" if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that nex...
38
1
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from t...
77
"""simple docstring""" def _A ( ): """simple docstring""" return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] UpperCAmelCase =generate_large_matrix() UpperCAmelCase =( [[4, 3, 2, -1], [3, ...
77
1
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
26
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def a__ ( lowercase : Iterable[str], lowercase : int ) -> Generator[tuple[str, ...], None, None]: """simple docstring""" _UpperCamelCase = ...
324
0
"""simple docstring""" import os import sys import transformers _lowercase : int = "3" print("Python version:", sys.version) print("transformers version:", transformers.__version__) try: import torch print("Torch version:", torch.__version__) print("Cuda available:", torch.cuda.i...
363
"""simple docstring""" from ...processing_utils import ProcessorMixin class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): '''simple docstring''' _a = 'SpeechT5FeatureExtractor' _a = 'SpeechT5Tokenizer' def __init__( self : D...
272
0
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.m...
25
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler,...
84
0
"""simple docstring""" import re from ..models.auto import AutoProcessor from ..models.vision_encoder_decoder import VisionEncoderDecoderModel from ..utils import is_vision_available from .base import PipelineTool if is_vision_available(): from PIL import Image class _SCREAMING_SNAKE_CASE ( SCR...
358
__A =''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.git ''' __A =[{'''typ...
47
0