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
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils impo...
277
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_...
185
0
from __future__ import annotations import requests def __lowercase ( __lowerCAmelCase : str ): a__ = F'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' return requests.get(__lowerCAmelCase ).json() def __lowercase ( ...
657
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
1
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class UpperCamelCase : lowercase = 42 lowercase = 42 class UpperCamelCase : def __init__( ...
425
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def lowercase__( __SCREAMING_SNAKE_CASE : Any , __SCREAMING_SNAKE_CASE : L...
425
1
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset 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, prepa...
694
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class snake_case ( __low...
694
1
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import Pr...
10
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, s...
554
0
"""simple docstring""" def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ): """simple docstring""" _enforce_args(UpperCamelCase__ , UpperCamelCase__ ) if n == 0: return 0 A__ = float('-inf' )...
536
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class UpperCamelCase__( unittest.TestCase ): def snake_case__ ( self ) -> str: A__ = get_activation('swis...
536
1
"""simple docstring""" from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, Def...
49
"""simple docstring""" def lowercase__ ( snake_case_ :Dict ): # noqa: E741 __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = 0 __UpperCAmelCase = [0] * n __UpperCAmelCase = [False] * n __UpperCAmelCase = [False] * n def dfs(sn...
49
1
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassific...
456
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids...
456
1
"""simple docstring""" import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() UpperCamelCase = logging.get_logger(__name__) def _...
104
from typing import List from .keymap import KEYMAP, get_character def lowercase__ ( A_: str ) -> str: """simple docstring""" def decorator(A_: int ): __UpperCAmelCase =getattr(A_ , """handle_key""" , [] ) ...
68
0
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 lowerCamelCase__ ( __lowerCAmelCase : Dict ...
705
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger _A = get_logger(__name__) _A = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):\n Indices of input...
279
0
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, p...
139
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class lowerCAmelCase__ : '''simple docstring''' @property def _lowe...
503
0
'''simple docstring''' import warnings 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 imp...
717
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask ...
40
0
"""simple docstring""" import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditi...
624
"""simple docstring""" import collections import os import re from pathlib import Path lowerCamelCase__ = "src/transformers" # Matches is_xxx_available() lowerCamelCase__ = re.compile(R"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} lowerCamelCase__ = re.compile(R"^_i...
624
1
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate _lowerCamelCase : Optional[Any] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("", ...
196
import cva import numpy as np class __snake_case : def __init__( self : List[str] , _UpperCAmelCase : float , _UpperCAmelCase : int ) -> int: '''simple docstring''' if k in (0.04, 0.06): _lowerCAmelCase : str = ...
196
1
import math def UpperCAmelCase_ ( UpperCAmelCase__ ): return math.sqrt(SCREAMING_SNAKE_CASE_ ) * math.sqrt(SCREAMING_SNAKE_CASE_ ) == num def UpperCAmelCase_ ( UpperCAmelCase__ ): lowercase_ = 0 lowercase_ = n while left <= right: lowercase_...
412
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "tiiuae/falcon-40b": "https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json", "tiiua...
18
0
'''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.conf...
666
'''simple docstring''' 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 SCREAMING_SNAKE_CASE : snak...
666
1
'''simple docstring''' from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def a_ ( UpperCamelCase_ = True , *UpperCamelCase_ , **UpperCamelCase_ ): if not is_tqdm_available(): r...
452
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.t...
452
1
class _lowerCAmelCase : """simple docstring""" def __init__( self : Tuple ) -> None: """simple docstring""" __lowercase = {} # Mapping from char to TrieNode __lowercase = False def s...
634
from __future__ import annotations from collections.abc import Callable UpperCamelCase__ = list[list[float | int]] def UpperCAmelCase__ ( lowercase__ , lowercase__ ) -> Matrix: __lowercase = len(lowercase__ ) __lowercase = [[0 for _ ...
634
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig class __A ( A ): '''simple docstring''' __lowerCamelCase : Any = 'bert-generation' def __init__(self , A=50_358 , A=1_024 , A=24 , A=16 , A=4_096 , A="gelu" , A...
11
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: __snake_case = None try: import msvcrt except ImportError: __snake_case = None try: import fcntl except ImportError: __snake_case = None ...
200
0
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.uti...
370
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfig...
370
1
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def UpperCAm...
534
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _UpperCamelCase ( _UpperCAmelCase ,_UpperCAmelCase ): """simple docstring""" @register_to_config def __init__( self , *, lowerCAmelCase__ = 4...
534
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A: Optional[int] = logging.get_logger(__name__) A: Any = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/con...
721
"""simple docstring""" import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class SCREAMING_SNAKE_CASE__ ( Upp...
359
0
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake __A =numpy.array([0, 0]) __A =numpy.array([0.5, 0.8_6_6_0_2_5_4]) __A =numpy.array([1, 0]) __A =[VECTOR_1, VECTOR_2, VEC...
407
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavin...
407
1
"""simple docstring""" import functools def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : list[int] ): '''simple docstring''' if not isinstance(a_ , a_ ) or not all(isinstance...
705
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseM...
363
0
import torch def UpperCAmelCase__ ( ): if torch.cuda.is_available(): __a : str = torch.cuda.device_count() else: __a : List[str] = 0 print(f'''Successfully ran on {num_gpus} GPUs''' ) if __name__ == "__main__": m...
47
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ = { '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowerC...
47
1
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score fro...
701
def _snake_case ( __snake_case , __snake_case ) -> int: '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def _snake_case ( ) -> None: '''simple docstring''' assert nand_gate(0 , 0 ) ...
455
0
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 snake_case__ : Any...
23
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils imp...
411
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IMAG...
594
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class _a ( lowerCamelCase_ ): """simple docstring""" def __lowerCAmelCase ( self , lowerCAmelCase_ ): return 0.0 def __lowerCamelCase ...
594
1
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase_ ( SCREAMING_SNAKE_CASE : ndarray ): """simple docstring""" return np.dot(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) c...
381
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowercase_ ( SCREAMING_SNAKE_CASE : Dataset , SCREAMING_SNAKE_CASE : Dic...
381
1
'''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_hp_spa...
609
'''simple docstring''' from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand a : Any = logging.get_logger(__name__) # pylint: disable=invalid-name def low...
609
1
'''simple docstring''' def snake_case_ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): """simple docstring""" _SCREAMING_SNAKE_CASE : Optional[Any] = """""" for word_or_phrase in separated: if not isinstance(A_ , A_ ): raise Exception("""j...
533
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __snake_case : List[Any] = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block...
660
0
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# a_ : List[Any] = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weight", "time_embedding.linear_1.weight"), ...
673
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-gpu-t...
673
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from trans...
92
from typing import TYPE_CHECKING from ...utils import _LazyModule __UpperCAmelCase = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __UpperCAmelC...
651
0
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __lowercase ...
703
"""simple docstring""" import sys __lowercase = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' ...
296
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = {} class _UpperCAmelCase ( _lowerCamelCase ): a = '''llama''' a = ['''past_key_values'''] def __in...
569
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 import TokenizerTesterMi...
569
1
from math import pow def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , ) -> Dict: if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. ...
712
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase =...
371
0
"""simple docstring""" import unittest from knapsack import knapsack as k class _UpperCAmelCase ( unittest.TestCase ): """simple docstring""" def a__ ( self ) -> List[str]: _lowerCamelCase : Optional[int] = 0 _lowe...
434
"""simple docstring""" import argparse import json import subprocess def UpperCamelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) ->Any: _lowerCamelCase : List[str] = [] _lowerCamelCase : Optional[int] = ( F'''curl -H "Accept: appli...
434
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class lowercase__( unittest.TestCase ): '''simple docstring''' def UpperCAmelCase ( self) -> Tu...
582
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _lowerCamelCase ( ) -> int: '''simple docstring''' UpperCamelCase__ : str =ArgumentParser( description=( "PyTorch...
582
1
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES lowerCAmelCase__ =logging.get_logger(__name__) lowerCAmelCase__ ...
482
"""simple docstring""" import argparse import os import re import packaging.version lowerCAmelCase__ ="examples/" lowerCAmelCase__ ={ "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(r"^__versio...
482
1
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__ ( __UpperCamelCase ): '''simple docstring''' ...
241
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 import TF...
241
1
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_config...
61
"""simple docstring""" def __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" try: _UpperCAmelCase = float(UpperCamelCase__ ) except ValueError: raise ValueError("Please enter a valid number" ) _UpperCAmelCase = decimal - int(UpperCamelCase__ ) if fractional_part == ...
657
0
"""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.image_utils import IMAGEN...
710
"""simple docstring""" from math import pi, sqrt def _snake_case ( snake_case__ : float ): if num <= 0: raise ValueError('math domain error' ) if num > 171.5: raise OverflowError('math range error' ) elif num - int(snake_case__ ) not in (0, 0.5): raise NotImplementedErr...
22
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_ex...
212
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def lowe...
316
0
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging ...
712
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowercase_ ( _snake_case ,_snake_case=7 ): SCREAMING_SNAKE_CASE__ : Dict = None if token is not None: SC...
545
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging __lowercase : List[str] ...
36
'''simple docstring''' import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_deter...
539
0
import glob import os import random from string import ascii_lowercase, digits import cva __UpperCAmelCase = "" __UpperCAmelCase = "" __UpperCAmelCase = "" __UpperCAmelCase = 1 # (0 is vertical, 1 is horizontal) def A_ ( ) ->int: """simple ...
706
import argparse from collections import defaultdict import yaml __UpperCAmelCase = "docs/source/en/_toctree.yml" def A_ ( lowercase_ ) ->Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE = defaultdict(lowercase_ ) for doc in model_doc: counts[doc["...
259
0
import torch from transformers import AutoModel class __lowerCAmelCase ( torch.nn.Module ): """simple docstring""" def __init__( self : str , _snake_case : str="sayef/fsner-bert-base-uncased" ): """simple docstring""" super(Up...
9
"""simple docstring""" def lowerCamelCase__ ( UpperCAmelCase_ = 60_08_51_47_51_43 )-> int: """simple docstring""" try: UpperCamelCase = int(UpperCAmelCase_ ) except (TypeError, ValueError): raise TypeError("P...
554
0
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __UpperCAmelCase ...
711
from __future__ import annotations from decimal import Decimal from numpy import array def a (lowerCAmelCase__ ): __a = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x2 matrices if len(lowerCAme...
209
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, Blip...
99
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
1
"""simple docstring""" from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward fro...
632
"""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_co...
632
1
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import ...
40
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : str =logging.get_logger(__name__) __lowerCAmelCase : Any ={ # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _lowercase ( A__ ):...
696
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_...
713
from manim import * class lowerCAmelCase_ ( lowercase ): """simple docstring""" def __a ( self :Optional[int] ): UpperCamelCase__ :Union[str, Any] = Rectangle(height=0.5 , width=0.5 ) UpperCamelCase__ :int = Rectang...
383
0
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 UpperCamelCase_ ( UpperCamelCase__ ...
6
from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Dict = logging.get_logger(__name__) _a : Union[str, Any] = { """google/vivit-b-16x2-kinetics400""": ( """https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json""" ...
145
0
'''simple docstring''' from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProces...
644
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class __a (lowerCamelCase , ...
644
1
from __future__ import annotations def _lowerCamelCase ( lowerCamelCase_: list[int] ): '''simple docstring''' if len(lowerCamelCase_ ) == 0: return array A , A : Tuple = min(lowerCamelCase_ ), max(lowerCamelCase_ ) # Co...
256
import os import sys import unittest UpperCamelCase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_bac...
256
1
from importlib import import_module from .logging import get_logger __lowerCamelCase : List[Any] = get_logger(__name__) class _lowercase : def __init__( self , a , a=None ): snake_case__ : str =attrs or [] if module is not None: ...
720
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __lowerCamelCase : str = models.Sequential() ...
448
0
def _lowerCAmelCase ( __magic_name__ :str , __magic_name__ :Union[str, Any] ): return price * (1 + tax_rate) if __name__ == "__main__": print(f"{price_plus_tax(100, 0.25) = }") print(f"{price_plus_tax(125.50, 0.05) = }")
121
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : str =logging.get_logger(__name__) __lowerCAmelCase : Any ={ # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _lowercase ( A__ ):...
696
0
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE ( a_ : int , a_ : str , a_ : Any ): if days_between_payments <= 0: raise ValueError('days_between_payments must be > 0' ) if daily_interest_r...
720
'''simple docstring''' import os def SCREAMING_SNAKE_CASE ( ): with open(os.path.dirname(a_ ) + '/grid.txt' ) as f: __a = [] # noqa: E741 for _ in range(20 ): l.append([int(a_ ) for x in f.readline().split()] ) __a = 0 # right...
490
0
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet i...
112
import pickle import numpy as np from matplotlib import pyplot as plt class __lowerCAmelCase : def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case , snake_case=0.2 , snake_case=0.2 ...
112
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCamelCase : List[str] = loggi...
718
'''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 UpperCamelCase : Optional[Any] = logging.get_logger(__name__) Upper...
610
0
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = loggi...
485
def _lowerCamelCase ( __A : str ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__A ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('doctest').testmod()
485
1
'''simple docstring''' import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from ...
713
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _UpperCamelCase : List[Any] = "\\n\n" _UpperCamelCase : List[Any] = "\...
514
0
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 torch.distributed...
23
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class lowercase : '''simple docstring''' def __init__(self , __a , __a , __a ) -> Union[str, Any]: """simple docstring""" if dst_width < 0 or dst_height < 0: ...
146
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( _lowerCAmelCase : list , _lowerCAmelCase : int ) -> List[str]: # Checks if the entire collection has been sorted if len(_lowerCAmelCase ) <= 1 or n <= 1: ...
528
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sq...
528
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_d...
288
'''simple docstring''' import os import sys import unittest __lowerCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, c...
288
1
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_do...
718
"""simple docstring""" import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common i...
22
0
'''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_full_determinism() class ...
517
'''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_hp_s...
517
1
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 / sqrt(2 ) ) -> IIRFilter: A__ = tau * frequency / samplerate A__ = sin(__UpperCamelCase ) A__ =...
52
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch SCREAMING_SNAKE_CASE__ = '''sshleifer/bart-tiny-random''' ...
52
1
'''simple docstring''' import random class _lowercase : @staticmethod def a ( SCREAMING_SNAKE_CASE_ : str ) -> tuple[list[int], list[int]]: __snake_case = [ord(SCREAMING_SNAKE_CASE_ ) for i in text] __snake_case = [] ...
56
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if ( (cp >= 0X4_e_0_0 and cp <= 0X9_f_f_f) or (cp >= 0X3_4_0_0 and cp <= 0X4_d_b_f) # o...
167
0
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for...
710
def snake_case (UpperCamelCase : Union[str, Any] ): '''simple docstring''' lowerCamelCase__ = 0 lowerCamelCase__ = len(UpperCamelCase ) for i in range(n - 1 ): for j in range(i + 1 , UpperCamelCase ): if arr[i] > arr[j]: num_invers...
235
0
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transform...
256
import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def _lowerCamelCase ( ): '''simple docstring''' print('''Making key files...''' ) make_key_files(''...
256
1
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils imp...
703
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def A ( Upper...
278
0
import sys def UpperCamelCase_( snake_case__: Dict ) -> Union[str, Any]: UpperCAmelCase__ = len(__UpperCamelCase ) UpperCAmelCase__ = [[0 for x in range(__UpperCamelCase )] for x in range(__UpperCamelCase )] UpperCAmelCase__ = [[0 for x in...
146
"""simple docstring""" def __lowerCamelCase ( __UpperCamelCase ) -> str: """simple docstring""" return "".join([hex(__UpperCamelCase )[2:].zfill(2 ).upper() for byte in list(__UpperCamelCase )] ) def __lowerCamelCase ( __UpperCamelCase ) -> byte...
610
0
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Tuple = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox...
720
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __magic_name__ ...
533
0
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel lowerCamelCase__ : Union[str, Any] = False lowerCamelCase__ : List[str] = True lowerCamelCase__ : Optional[Any] ...
31
"""simple docstring""" import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def __A ( a_ :Union[str, Any] , a_ :Union[str, Any] , a_ :Optional[Any] , a_ :Optional[int]=5) -> List[Any]: # Adapted from https://github...
52
0
def UpperCAmelCase__ ( UpperCAmelCase__ :int = 10_00 ): '''simple docstring''' a , a = 1, 1 a = 2 while True: a = 0 a = fa + fa a , a = fa, f index += 1 for _ in str(UpperCAmelCase__ ): i += 1 if i == n: break ...
32
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass A_ : List[str] = (3, 9, -11, 0, 7, 5, 1, -1) A_ : Optional[int] = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _lowercase : _UpperCAmelCase ...
32
1
'''simple docstring''' def lowercase__ ( __UpperCamelCase : int , __UpperCamelCase : int ): '''simple docstring''' return "\n".join( F'''{number} * {i} = {number * i}''' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(mult...
566
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Tuple = logging.get_logger(__...
566
1
'''simple docstring''' from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets snake_case_ : str = '\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\n ...
350
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if...
350
1
from queue import PriorityQueue from typing import Any import numpy as np def __snake_case ( __UpperCamelCase : dict ,__UpperCamelCase : str ,__UpperCamelCase : set ,__UpperCamelCase : set ,__UpperCamelCase : dict ,__UpperCamelCase : dict ,__UpperCamelCase : PriorityQueue ,__U...
86
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_d...
555
0
'''simple docstring''' import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py lowerCAmelCase_ : Optional[int] = '''src/diffusers''' # Matches is_xxx_available() lowerCA...
156
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ : List[str] = { '''configuration_layoutlmv2''': ['''L...
156
1
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, ...
682
"""simple docstring""" import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, ...
682
1
"""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 ( HPSearch...
702
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE = { """configuration_graphormer""": ["""GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GraphormerConfig...
556
0
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class __lowercase ( _lowercase ): def __init__(self , A , A = None , A = None , A = Fal...
422
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def lowercase_ ( _lowercase ) -> str: '''simple docstring''' if ( (cp >= 0x4_E_0_0 and cp <= 0x9_F_F_F) or (cp >= 0x3_4_0_0 and cp <= 0...
422
1
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_...
715
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...
5
0
import math from collections.abc import Iterator from itertools import takewhile def UpperCAmelCase_ ( __lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, ...
509
import numpy as np class __lowerCAmelCase : """simple docstring""" def __init__( self : Union[str, Any] ): __lowercase : Optional[int] = (0, 0) __lowercase : List[str] = None __low...
509
1
import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __magic_name__ ( __lowerCAmelCase): A: Optional[int] = (EulerDiscreteScheduler,) A: List[Any] = 1_0 def UpperCAm...
707
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __UpperCamelCase : Dict = { "configuration_trocr": ["TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
106
0
"""simple docstring""" import math def __magic_name__ ( __snake_case : int ) -> Any: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, ...
361
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case_ : float , snake_case_ : float , snake_case_ : float ): if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: raise Valu...
297
0
"""simple docstring""" import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _UpperCamelCase : Optional[int] = logging.get_logger('transformers.models.speecht5') def _SCREAMING_SNAKE_CASE ( __sna...
708
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fro...
134
0
"""simple docstring""" import random class snake_case_ : """simple docstring""" @staticmethod def UpperCAmelCase__ ( lowerCamelCase_) -> tuple[list[int], list[int]]: UpperCamelCase = [ord(lowerCamelCase_) for i in text] UpperCamelCase ...
34
"""simple docstring""" # Imports import numpy as np class __a : def __init__( self , a__=None , a__=None , a__=None , a__=None , a__=None ): self.set_matricies(red=a__ , green=a__ , blue=a__ , red_edge=a__ , nir=a__ ) def snake_case_ ( self...
650
0
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _lowerCAmelCase ( ) -> Tuple: _SCREAMING_SNAKE_CASE : str = { "repo_name": ["test_repo1", "test_re...
720
"""simple docstring""" from __future__ import annotations lowercase_ : List[str] = '''#''' class UpperCamelCase : def __init__( self ): """simple docstring""" _SCREAMING_SNAKE_CASE : dict = {} def __SCREAMING_SNAKE_CASE...
295
0
'''simple docstring''' import numpy as np from PIL import Image def lowerCAmelCase_ ( snake_case_ : Optional[int] , snake_case_ : Dict , snake_case_ : Any ) -> np.ndarray: '''simple docstring''' UpperCAmelCase_ = np.array(snak...
78
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin lowerC...
678
0
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from fl...
296
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging __lowercase = logging.get_logger(__name__) def lowe...
296
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''InstructBlipQFormerConfig'''...
513
from cva import destroyAllWindows, imread, imshow, waitKey def __magic_name__ ( __a : List[Any] ): '''simple docstring''' UpperCamelCase__ , UpperCamelCase__ = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i i...
513
1
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, ) from...
268
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, UNet...
268
1
from collections.abc import Sequence def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> float: return sum(c * (x**i) for i, c in enumerate(__snake_case ) ) def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> float: _Up...
108
'''simple docstring''' def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 _lowerCAmelCase = 1 _lowerCAmelCase = 1 while repunit: _low...
207
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_v...
706
"""simple docstring""" from math import factorial def a__ ( SCREAMING_SNAKE_CASE : int = 1_0_0 ): '''simple docstring''' return sum(int(SCREAMING_SNAKE_CASE ) for x in str(factorial(SCREAMING_SNAKE_CASE ) ) ) if __name__ == "__main__": p...
681
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutp...
137
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case__ : Dict = { """configuration_whisper""": ["""WHISPER_PRETRAINED_CONFIG_ARCHI...
402
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltCLIPTextConfig", ...
703
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor __UpperCAmelCase = logging.get_logger(__name__) class A__ ( A ): """simple docstring""" def __init__( self : Tuple , *A_ : Optional[int] , **A_ : int ...
503
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { """microsoft/git-base""": """https://huggingfa...
295
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase = 200 ) -> int: lowerCamelCase__ : Dict = [1, 2, 5, 10, 20, 50, 100, 200] lowerCamelCase__ : Union[str, Any] = [0] * (pence + 1) lowerCamelCase__ : List[str] = 1 # base case: 1 way to make 0 ...
295
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''edbeeching/decision-transformer-gym-hopper-medium''': ( '''https://huggingface.co/edbeeching/decision-transformer-gym-ho...
707
def lowercase_ ( SCREAMING_SNAKE_CASE : str ): """simple docstring""" snake_case__ : Optional[int] =len(SCREAMING_SNAKE_CASE ) snake_case__ : int =sum(SCREAMING_SNAKE_CASE ) snake_case__ : str =[[False for x in range(s + 1 )] for y in range(n + 1 )] for i...
408
0