code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import sys a__ : Tuple = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '66896648...
80
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent a__ : Tuple = {'UserAgent': UserAgent().random} def _UpperCamelCase ( __A ) -> dict: '''simple docstr...
80
1
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow UpperCAmelCase_ = logging.getLogger() @unittest.skip("Temporarily...
361
from manim import * class lowercase__ ( __lowerCamelCase ): '''simple docstring''' def UpperCamelCase__ ( self ) -> int: """simple docstring""" UpperCamelCase__ : int = Rectangle(height=0.5, width=0.5 ...
247
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # Initialise PyTorch model __a = ...
49
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import Au...
137
0
'''simple docstring''' import inspect import unittest class __snake_case( unittest.TestCase ): '''simple docstring''' def __snake_case ( self ) -> Tuple: try: import diffusers # noqa: F401 except ImportError: assert False ...
187
'''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 TensorType ...
187
1
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = {name: g...
251
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class _a : '''simple docstring''' def __init__( self, A ): '''simple docstring''' ...
251
1
def _a ( a :str , a :str ) -> str: a = len(a ) a = len(a ) a = ( first_str_length if first_str_length > second_str_length else second_str_length ) a = [] for char_count in range(a ): if char_count < first_str_length: ...
26
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer UpperCAmelCase__ = logging.get_logger(__name...
26
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class __A ( _SCREAMING_SNAKE_CASE ): """simple docstring""" @staticmethod @abstractmethod def SCREAMING_SNAKE_CASE ( __A ) ...
81
import argparse import json from tqdm import tqdm def UpperCamelCase ( ) -> Optional[int]: UpperCamelCase : List[Any] = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=snake_case__ , default='biencoder-nq-dev.json' ...
119
0
import os import pytest from transformers.dynamic_module_utils import get_imports __a = ''' import os ''' __a = ''' def foo(): import os return False ''' __a = ''' def foo(): def bar(): if True: import os return False return bar() ''' __a = '...
173
from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json''' ), } class ...
173
1
import qiskit def __lowerCamelCase ( snake_case__ = 2 ) -> qiskit.result.counts.Counts: """simple docstring""" _SCREAMING_SNAKE_CASE = qubits # Using Aer's simulator _SCREAMING_SNAKE_CASE = qiskit.Aer.get_backend("""aer...
306
__UpperCAmelCase : int = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import ArrayaD, A...
111
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Any = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_visi...
104
'''simple docstring''' import unittest from transformers import DebertaConfig, 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_com...
104
1
class _SCREAMING_SNAKE_CASE : def __init__( self , lowercase , lowercase , lowercase ) -> str: lowerCamelCase_ = name lowerCamelCase_ = value lowerCamelCase_ = weight def __repr__( self ) -> Dict: return f'{self.__class_...
19
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dist...
19
1
# 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 import...
261
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`''')
261
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
30
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils impo...
156
0
import functools def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> int: # Validation if not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) or not all(isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) for day in days ...
351
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate lowerCamelCase__ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("""""", """|""", """|"""...
307
0
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE_...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from tra...
319
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE ( lowerCAmelCase ): '''simple docstring''' UpperCamelCase_ : Dict = '''timm_backbone''' def __ini...
319
1
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : List[str] = logging.get_logger(__name__) lowercase__ : Any = ...
187
def lowerCamelCase__ ( _A , _A ): '''simple docstring''' _enforce_args(_A , _A ) if n == 0: return 0 snake_case_ = float("-inf" ) for i in range(1 , n + 1 ): snake_case_ = max( _A , prices[i - 1]...
187
1
"""simple docstring""" 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 impor...
358
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __A = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xlm''': ['...
64
0
_snake_case = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" _snake_case = [{"type": "code", "content": INSTALL_CONTENT}] _snake_case ...
26
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlitea import s...
26
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) __UpperCamelCase : Tuple = { '''configuration_speech_to...
362
"""simple docstring""" import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring""" lowercase__ = "" lowercase__ = ( ...
74
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase = { """configuration_roformer""": ["""ROFO...
173
"""simple docstring""" # flake8: noqa # Lint as: python3 _UpperCAmelCase = [ """VerificationMode""", """Version""", """disable_progress_bar""", """enable_progress_bar""", """is_progress_bar_enabled""", """experimental""", ] from .info_utils import VerificationMode from .l...
173
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase_ = { """configuration_gpt_neo""": ["""GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoConfig""", """GPTNeoOnnxConfig"""], } try: if not is...
356
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available()...
178
0
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowercase_ : """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Union[str, Path]] = None SCREAMING_SNAKE_CASE : bool ...
104
'''simple docstring''' 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 PreTrainedTokeniz...
104
1
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _A ( lowerCAmelCase_ : Optional[Any] , lowerCAmelCase_ : str , lowerCAmelCase_ : Union[str, Any] = 1 / sqrt(2 ) ): """simple docstring""" lowerCAm...
358
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block ...
221
0
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data im...
261
"""simple docstring""" from collections import Counter from timeit import timeit def _lowerCamelCase( a = "" , ): return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def _lowerCamelCase( a = "" ): if len(a ...
261
1
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 A ( _UpperCAmelCase ): ...
282
from __future__ import annotations from scipy.special import comb # type: ignore class A : """simple docstring""" def __init__( self : Any,lowercase_ : list[tuple[float, float]] )-> Optional[int]: '''simple docstring''' ...
282
1
"""simple docstring""" from math import isclose, sqrt def lowercase ( A_ , A_ , A_ )-> tuple[float, float, float]: '''simple docstring''' a : Optional[int] = point_y / 4 / point_x a : Any = 2 * normal_gra...
40
import random from typing import Any def a_ ( _A ) -> list[Any]: """simple docstring""" for _ in range(len(_A ) ): snake_case__ = random.randint(0 , len(_A ) - 1 ) snake_case__ = random.randin...
307
0
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_camembert import ...
350
import copy import re class _SCREAMING_SNAKE_CASE : lowerCAmelCase__ = 'hp' lowerCAmelCase__ = {} lowerCAmelCase__ = None @classmethod def SCREAMING_SNAKE_CASE_( cls , lowercase , lowercase ) -> Tuple: lowerCamelCase_ = prefix ...
47
0
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def UpperCamelCase__ ( ) -> Optional[Any]: snake_case__ : Dict = { 'repo_name': ['test_repo1', 'test_repo2', 'test_repo3'], ...
143
'''simple docstring''' def _lowercase ( __A ,__A ): '''simple docstring''' __UpperCamelCase = len(__A ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by no...
349
0
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from tra...
353
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class a : """simple docstring""" SCREAMING_SNAKE_CASE : torch.Tensor # [batch_size x 3] SCREAMING_SNAKE_CASE : torch.Tenso...
240
0
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class A_ ( __a ): '''simple docstring''' _UpperCamelCase : Optional[Any] = (DDIMParallelScheduler,) _UpperCamelCase : List[str] = (("""eta""...
195
"""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()...
64
0
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_barthez impor...
223
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Optional[int] = logging.get_logger(__name__) lowerCamelCase_ : Dict = { """studio-ousia/luke-base""": """https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json""", """studio-o...
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_configuration_common ...
77
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def...
74
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(_...
369
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion import S...
218
0
'''simple docstring''' from math import factorial, radians def lowerCAmelCase_ ( snake_case__ , snake_case__ = 18 , snake_case__ = 10 ): '''simple docstring''' A : List[str] = angle_in_degrees - ((angle_in_degrees // 3_60.0) * 3_60.0...
3
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(): from transform...
178
0
import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants UpperCAmelCase_ : str = Mapping[str, np.ndarray] UpperCAmelCase_ : Union[str, Any] = Mapping[str, Any] # Is a nested dict. ...
360
def SCREAMING_SNAKE_CASE_ ( __A : int , __A : int ) -> int: """simple docstring""" while b: a_ , a_ : int = b, a % b return a def SCREAMING_SNAKE_CASE_ ( __A : int , __A : int ...
120
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCAmelCase : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else:...
253
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_torch_available(): import t...
253
1
from __future__ import annotations def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase, ): lowercase :Tuple = len(lowerCamelCase ) # If row is equal to the size of the board it means there are a queen in each row in...
350
import pytest _UpperCAmelCase : List[Any] = "__dummy_dataset1__" _UpperCAmelCase : Union[str, Any] = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"wikiann-bn-...
158
0
from __future__ import annotations import time _lowerCamelCase : Union[str, Any] = list[tuple[int, int]] _lowerCamelCase : Union[str, Any] = [ [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], [0, 0, 1,...
282
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor _lowerCamelCase : Dict = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( UpperCAmelCase ): '''simple docstring''' def __init__( self : Tuple ,...
282
1
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : float , ): """simple docstring""" __UpperCamelCase =[redshift, radiation_de...
350
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
85
0
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceCl...
47
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCamelCase : Optional[int] = False class A__ ( ...
47
1
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, i...
32
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :int ) -> int: '''simple docstring''' if not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): raise TypeError("""only integers accepted as input""" ) else: lowercase ...
32
1
from ....configuration_utils import PretrainedConfig from ....utils import logging A__ : Optional[int] = logging.get_logger(__name__) # TODO: upload to AWS A__ : Tuple = { 'yjernite/retribert-base-uncased': ( 'https://huggingface.co/yjernite/retribert-base-uncased/resolve/main/config...
207
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate...
292
0
"""simple docstring""" class __A : '''simple docstring''' def __init__( self : Optional[Any] , UpperCAmelCase_ : int ) ->Tuple: """simple docstring""" snake_case_ = val snake_case_ = ...
364
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def _a ( _SCREAMING_SNAKE_CASE = 8 ) -> str: snake_case_ = ascii_letters + digits + punctuation return "".join(secre...
233
0
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingfa...
302
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_info()...
302
1
"""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 t...
350
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def a_ ( _lowercase ): # This defines a "chinese character" as anything in the CJK Unicode bl...
128
0
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 snake_case__(lowerCAmelCase_ , unittest.TestCase ): "...
130
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...
218
0
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_availabl...
318
"""simple docstring""" import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.d...
318
1
import pytest import datasets # Import fixture modules as plugins snake_case_ : Tuple = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def A (__A : Optional[int] , __A : Any ) -> Optional[int]: """simple ...
51
'''simple docstring''' from statistics import mean, stdev def UpperCamelCase_ ( A__ : list , A__ : int = 3 ): '''simple docstring''' lowerCAmelCase_ : List[str] = min(A__ ) lowerCAmelCase_ : Optional[int] = ...
120
0
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class UpperCAmelCase__ ( A__ ): """simple docstring""" def lowercase_ ( self : Any , __lowerCamelCase : str ) -> List[str]: with open(__lowerCame...
362
import argparse import copy def UpperCAmelCase_ ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = {} with open(_A ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: SCREAMING_SNAKE_CASE__ = [] ...
218
0
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table impo...
107
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import...
158
0
"""simple docstring""" def a__ ( __lowercase , __lowercase ) -> Any: def get_matched_characters(__lowercase , __lowercase ) -> str: _A = [] _A = min(len(_stra ) , len(_stra ) ) // 2 for i...
353
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, sl...
163
0
"""simple docstring""" A: Optional[int] = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" A: List...
109
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def UpperCame...
85
0
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMi...
170
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_...
170
1
import random def SCREAMING_SNAKE_CASE_ ( __A : int ) -> bool: """simple docstring""" a_ : Union[str, Any] = num - 1 a_ : List[Any] = 0 while s % 2 == 0: a_ : Optional[int] = s // 2 ...
32
import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase_ : str ...
32
1
"""simple docstring""" import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP lowerCAmelCase__ = False try: lower...
175
"""simple docstring""" import math def snake_case_ ( A_ : int ): '''simple docstring''' return math.sqrt(A_ ) * math.sqrt(A_ ) == num def snake_case_ ( A_ : int ): '''simple docstring''' _lowerCamelCase : Dict ...
175
1
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowercase ( lowercase_ ): __SCREAMING_SNAKE_CASE...
285
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( 'files' , [ ['full:README.md', 'dataset_infos.json'], ['empty:README.md', 'dataset_infos.json'], ['dat...
285
1
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase_ : Optional[int] = logging.get_logger(__name__) lowerCamelCase_ : Optional[...
350
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _UpperCamelCase ( _A , unittest.TestCase ): '''simple docstring''' __UpperCamelCase : Tu...
223
0
'''simple docstring''' import os _SCREAMING_SNAKE_CASE : int = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} def UpperCamelCase_( snake_case : str ): '''simple docstring''' snake_case_ = 0 snake_case_ = ...
85
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCAmelCase : Dict =argparse.ArgumentParser() parser.add_argument("""--dump_path""", default=None...
128
0
"""simple docstring""" import math import sys import cva import numpy as np def SCREAMING_SNAKE_CASE ( _lowerCamelCase : np.ndarray ,_lowerCamelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. _lowerCAmelCase : Optional[A...
126
"""simple docstring""" 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_tokenizer...
126
1
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
318
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProces...
318
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor __snake_case : Optional[int] = logging.get_logger(__name__) class lowerCamelCase ( lowercase_ ): '''simple docstring''' def...
354
'''simple docstring''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase ( lowercase_ ): '''simple docstring''' __snake_case = (CMStochasticIterativeScheduler,) __snake_case = 10 ...
136
0
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils import l...
244
lowerCamelCase_ = frozenset( [ '''prompt''', '''height''', '''width''', '''guidance_scale''', '''negative_prompt''', '''prompt_embeds''', '''negative_prompt_embeds''', '''cross_attention_kwargs''', ] ) lowerCamelCase_ = frozen...
244
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : Optional[Any] = { 'configuration_roformer': ['ROFORMER_...
236
'''simple docstring''' class lowercase__ : def __init__( self : List[str] ,lowerCamelCase__ : List[Any] ,lowerCamelCase__ : Optional[int] ,lowerCamelCase__ : Any ): '''simple docstring''' _UpperCamelCase : Dict = None _UpperCamelCase : ...
236
1
__lowerCAmelCase : Any = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' __lowerCAmelCase : List[str] = [{'type': 'code', 'content': INSTAL...
88
'''simple docstring''' from collections import namedtuple import requests from lxml import html # type: ignore __A =namedtuple('covid_data', 'cases deaths recovered') def _UpperCamelCase ( UpperCamelCase__ = "https://www.worldometers.info/coronavirus/" ): UpperCAm...
163
0
import re def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> bool: UpperCamelCase__ : Union[str, Any] = re.compile( R"^(?:0|94|\+94|0{2}94)" R"7(0|1|2|4|5|6|7|8)" R"(-| |)" R"\d{7}$" ) return bool(re.search(__lowerCAmelCase , _...
355
from ..utils import DummyObject, requires_backends class __a ( metaclass=A__ ): _lowerCAmelCase : str = ['''torch'''] def __init__( self : int , *SCREAMING_SNAKE_CASE : Optional[Any] , **SCREAMING_SNAKE_CASE : List[str] ...
196
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...
170
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logg...
170
1
'''simple docstring''' def UpperCAmelCase ( a_ ) -> int: """simple docstring""" if not numbers: return 0 if not isinstance(a_ , (list, tuple) ) or not all( isinstance(a_ , a_ ) for number in numbers ): raise ValueError("""num...
355
'''simple docstring''' import math def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" return math.sqrt(a_ ) * math.sqrt(a_ ) == num def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" ...
164
0
import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replic...
175
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP a_ = False try: a_ = _is_package_available('goog...
175
1
from PIL import Image def A ( lowercase , lowercase ) -> Image: '''simple docstring''' def brightness(lowercase ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise ValueError('level must be between -255.0 (black) and 255.0 (white)' ) return img.p...
356
from __future__ import annotations def A ( lowercase , lowercase , lowercase , lowercase ) -> list: '''simple docstring''' UpperCamelCase = [] UpperCamelCase , UpperCamelCase = input_list[low:mid], input_list[mid : high + 1] while left and right: result....
110
0
"""simple docstring""" import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaa...
54
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import to...
223
0
"""simple docstring""" from typing import TYPE_CHECKING from ..models.auto import AutoModelForVisionaSeq from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class UpperCamelCase ( lowercase_ ): lowercase = 'Salesforce/bli...
371
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_att...
321
0
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets lowerCAmelCase = """ IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For bina...
126
"""simple docstring""" import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaF...
126
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' lowercase_ = [1] lowercase_ , lowercase_ , lowercase_ = 0, 0, 0 lowercase_ = ugly_nums[ia] * 2 lowercase_ = ugly_nums[ia]...
366
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> list[str]: '''simple docstring''' if nth_term == "": return [""] lowercase_ = int(__lowerCAmelCase ) lowercase_ ...
313
0
import logging import os from .state import PartialState class A__ ( logging.LoggerAdapter ): """simple docstring""" @staticmethod def __lowercase ( lowercase) -> int: '''simple docstring''' a__ : Any = PartialState() ...
99
"""simple docstring""" from math import isqrt, loga def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> list[int]: '''simple docstring''' lowercase_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prim...
136
0
"""simple docstring""" import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Token...
182
"""simple docstring""" lowerCamelCase__ = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader imp...
182
1
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path __snake_case = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # ...
310
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __snake_case = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def _A ( _lowercase = "mumbai" ) -> Generator[tuple[str, s...
310
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ) -> np.ndarray: # prepare kernel ...
166
"""simple docstring""" from math import factorial, radians def a__ ( lowerCAmelCase , lowerCAmelCase = 18 , lowerCAmelCase = 10 ) -> float: UpperCAmelCase__ : List[Any] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radians ...
166
1
'''simple docstring''' import os from pathlib import Path def __lowerCAmelCase ( ) -> Optional[int]: from torch.utils.cpp_extension import load __lowerCamelCase = Path(UpperCamelCase__ ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' __lowerCamelCase = [ ...
67
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 ...
196
0
from math import factorial lowerCAmelCase_ = {str(d): factorial(d) for d in range(10)} def lowerCamelCase_ ( lowerCAmelCase: int )-> int: return sum(DIGIT_FACTORIAL[d] for d in str(lowerCAmelCase ) ) def lowerCamelCase_ ( )-> int: _snake_case : str ...
260
lowerCAmelCase_ = 256 # Modulus to hash a string lowerCAmelCase_ = 100_0003 def lowerCamelCase_ ( lowerCAmelCase: str , lowerCAmelCase: str )-> bool: _snake_case : Optional[int] = len(lowerCAmelCase ) _snake_case : int = ...
260
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCAmelCase__(__snake_case ,__snake_case=False ) -> Tuple: '''simple docstring''' lowerCamelCase__ = OmegaConf.load(lowercase__ ) if dis...
209
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A = logging.get_logger(__name__) __A = { "facebook/convnextv2-tiny-1k-224": "https://...
164
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> int: return int((input_a, input_a).count(0 ) == 0 ) def SCREAMING_SNAKE_CASE__ ( ) -> None: assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gat...
2
"""simple docstring""" import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
2
1
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : Any = logging.get_logger(__name__) UpperCAmelCase__ : str = { 'snap-research/efficientformer-l1-300': ( ...
25
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'], } try...
110
0
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowerCAmelCase_ : str = HfArgumentParser(InitializationArguments) lowerCAmelCase_ : Tuple = parser....
356
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under...
248
0
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup _lowerCamelCase =logging.get_logger(__name__) class A__ ( __SCR...
287
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from ...
321
0
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xform...
139
from pathlib import Path import fire def snake_case_ (__A : str , __A : str , __A : int ) -> Any: __lowerCAmelCase : Tuple = Path(__A ) __lowerCAmelCase : Tuple = Path(__A ) dest_dir.mkdir(exist...
139
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats...
167
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def snake_case_ ( lowerCAmelCase_ : int = 8 ): __lowercase : str = ascii_letters + digits + punctuation return "".join(secrets.choice(l...
233
0
"""simple docstring""" 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 PreTrainedTokeni...
27
"""simple docstring""" from typing import Any class lowerCamelCase : def __init__( self , SCREAMING_SNAKE_CASE_ ): UpperCamelCase : Optional[int] = data UpperCamelCase : Optional[Any] = None def __repr__( self ):...
27
1
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers imp...
182
from math import ceil def A ( _lowercase = 1_001 ): SCREAMING_SNAKE_CASE : Any = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): SCREAMING_SNAKE_CASE : Union[str, Any] = 2 * i + 1 SCREAMING_SNAKE_CASE ...
182
1
import re def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> bool: UpperCamelCase__ : Union[str, Any] = re.compile( R"^(?:0|94|\+94|0{2}94)" R"7(0|1|2|4|5|6|7|8)" R"(-| |)" R"\d{7}$" ) return bool(re.search(__lowerCAmelCase , _...
365
from collections.abc import Generator from math import sin def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> bytes: if len(__lowerCAmelCase ) != 32: raise ValueError("Input must be of length 32" ) UpperCamelCase__ : Optional[A...
196
0
'''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 ...
166
'''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 lowerCamelCase = ( """This metric will be removed from the lib...
166
1
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _snake_case ( UpperCA...
69
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int = 50 ): A__ = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length +...
69
1
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics...
260
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : list ): '''simple docstring''' if len(_SCREAMING_SNAKE_CASE ) <= 1: return lst _UpperCAmelCase = 1 while i < len(_SCREAMING_SNAKE_CASE ): if lst[i - 1] <= lst...
260
1
from __future__ import annotations def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ) -> float: """simple docstring""" if days_between_payments <= 0: raise ValueError("""days_between_payments must be > 0""" ) if dail...
125
def __lowerCamelCase ( snake_case__ ) -> List[Any]: """simple docstring""" _SCREAMING_SNAKE_CASE = len(snake_case__ ) for i in range(length - 1 ): _SCREAMING_SNAKE_CASE = i for k in range(i + 1 ,snake_c...
125
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE (A , A ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def _SCREAMING_SNAKE_CASE () -> None: """simple docstring""" assert and_...
2
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : List[Any] = { 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface.co/google/realm-c...
2
1
'''simple docstring''' def lowerCamelCase__ ( A : int = 10_00 ): '''simple docstring''' UpperCAmelCase = 3 UpperCAmelCase = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 ...
367
'''simple docstring''' import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import ji...
91
0
from __future__ import annotations import bisect def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase = 0 , _UpperCamelCase = -1 ) -> str: """simple docstring""" if hi < 0: snake_case_ : List[str] = len(a__ ) while lo...
279
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
248
0
'''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 f...
52
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCAmelCase__ = logging.get_logger(__name__) # pylint: disable=invalid-name class lower...
52
1
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpo...
139
'''simple docstring''' # 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 A_ ( snake_case ): return 1 / (1 + np.exp(-z )) ...
139
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common ...
23
"""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 = ( 'This metric will be removed from the library soon, met...
23
1