code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class __lowerCAmelCase ( unittest.TestCase ): lowerCamelCase_ : Tuple = inspect....
60
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "BAAI/AltCLIP": "https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json", # See all AltCLIP mode...
307
0
"""simple docstring""" import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter _UpperCame...
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 unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken ...
118
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": _lowercase = pd.read_csv('''sample_data.csv''', head...
118
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class __UpperCAmelCase : def __init__( self , _lowerCamelCase ): lowerCAmelCase_ = value lowerCAmelCase_ = None lowerCAmelCase_ = None ...
606
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, Sta...
606
1
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configura...
51
'''simple docstring''' import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def __snake_case ( ...
51
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def UpperCamelCase (lowercase_: Union[str, Any] ) -> Tuple: A__ : Dict = {} A__ : Optional[int] = job["""started_at"""] A__ : Tuple = job["""comple...
64
def UpperCamelCase (lowercase_: str , lowercase_: str ) -> bool: A__ : Union[str, Any] = len(lowercase_ ) A__ : List[Any] = len(lowercase_ ) A__ : List[Any] = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] A__ ...
64
1
'''simple docstring''' import collections import importlib.util import os import re from pathlib import Path _UpperCamelCase = """src/transformers""" # Matches is_xxx_available() _UpperCamelCase = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct...
111
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _UpperCamelCase = {"""configuration_vit""": ["""VIT_PRETRAI...
111
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer A = logging.get_logger(__name__) A = {'vocab_file': 'voca...
713
from timeit import timeit def _lowerCamelCase( lowerCAmelCase__ : int ): '''simple docstring''' if number < 0: raise ValueError('the value of input must not be negative' ) SCREAMING_SNAKE_CASE_ : Tuple = 0 while number: number &=...
97
0
'''simple docstring''' import unittest import torch from torch import nn from diffusers.models.activations import get_activation class UpperCAmelCase__ ( unittest.TestCase): def __lowerCamelCase ( self ) -> Optional[Any]: __UpperCamelCase = get_activation...
601
'''simple docstring''' from __future__ import annotations def _lowercase ( __A ,__A ,__A ,__A ,__A ,): '''simple docstring''' __UpperCamelCase = len(__A ) # If row is equal to the size of the board it means there are a queen in each row in ...
601
1
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _lowerCAmelCase ( _UpperCAmelCase , unittest.Te...
707
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
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''Intel/dpt-large''': '''https://huggingface.co/In...
83
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational i...
661
0
'''simple docstring''' import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig __a = logging.get_logger(__name__) __a = "T5Config" def __snake_case( ...
301
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blank...
301
1
"""simple docstring""" import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup UpperCAmelCase__ = { """User-Agent""": """Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36""" """ (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge...
277
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class a ( __lowerCAmelCase ): """simple docstring""" ...
401
0
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_va...
574
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
574
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_mo...
90
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class snake_case__ ( SCREAMING_SNAKE_CASE_ ): A__ = ['''image_processor''', '''tokenizer'''] A__ = '''AutoImageProcessor''' A__ = '''AutoTokenizer'''...
286
0
"""simple docstring""" __lowerCAmelCase = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm''', '''yott...
396
"""simple docstring""" import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename __lowerCAmelCase = '''http:...
396
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
330
'''simple docstring''' from typing import Any class _UpperCAmelCase : """simple docstring""" def __init__( self : List[Any] , __UpperCAmelCase : Any ): '''simple docstring''' _A = data _A = None class ...
330
1
def lowercase_ ( __snake_case : str , __snake_case : Any ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) snake_case__ :Dict = str(bin(lowerCamelCase__ ) ...
710
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __UpperCAmelCase : Tuple = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable...
57
0
'''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 _SCREAMING_SNAKE_CASE = logging.get_logger(__name...
502
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logge...
502
1
def a__ ( a = 1_0**1_2 ) -> int: A_ : Optional[Any] = 1 A_ : Optional[Any] = 0 A_ : Optional[Any] = 1 A_ : Dict = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2...
715
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = {'vocab_file': 'vocab.txt'} _lowerCAmelCase ...
236
0
"""simple docstring""" import os import numpy import onnx def _snake_case ( _snake_case : Optional[Any] , _snake_case : Any ) -> Dict: '''simple docstring''' _A = a.name _A = b.name _A = '' _A = '' _A = ...
7
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Union[str, Any] = logging.get_logger(__name__) __A : Any = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class __lowerCAmelCa...
656
0
import argparse from collections import defaultdict import yaml _lowercase : Dict = "docs/source/en/_toctree.yml" def _lowerCAmelCase ( UpperCamelCase__: Dict ) -> Dict: """simple docstring""" A = defaultdict(UpperCamelCase__ ) for doc in model_doc: ...
546
import os def _lowerCAmelCase ( UpperCamelCase__: str = "matrix.txt" ) -> int: """simple docstring""" with open(os.path.join(os.path.dirname(UpperCamelCase__ ) , UpperCamelCase__ ) ) as in_file: A = in_file.read() A = [[int(UpperCa...
546
1
import os from collections import deque import torch from torch.utils.data import Dataset class __SCREAMING_SNAKE_CASE ( lowercase): def __init__( self : Optional[int] , __UpperCamelCase : List[str]="" , __UpperCamelCase : Optional[Any]="train" ): ...
684
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( lowercase): __SCRE...
684
1
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow_memo...
704
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeechConfig''']} t...
102
0
'''simple docstring''' import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = ...
638
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.co...
638
1
import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimensio...
721
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, SingleSentenceClassificat...
648
0
"""simple docstring""" from __future__ import annotations from cmath import sqrt def __lowercase ( _a , _a , _a ): if a == 0: raise ValueError('''Coefficient \'a\' must not be zero.''' ) snake_case_ : Optional[int] = b * b - 4 * a * c s...
123
"""simple docstring""" from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class UpperCamelCase_ ( a_ )...
673
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : Optional[int] = logging.get_logger(__name__) snake_case_ : Optional[int] = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", ...
717
import math from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : Dict = logging.get_logger(__name__) snake_case_ : List[Any] = { "facebook/data2vec-base-960h": "https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/mai...
169
0
from collections import namedtuple import requests from lxml import html # type: ignore __lowerCamelCase : Optional[Any] = namedtuple("""covid_data""", """cases deaths recovered""") def SCREAMING_SNAKE_CASE ( snake_case_ : str = "https://www.worldometers.info/coronavirus/" ): ...
297
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : Tuple = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatureExtract...
297
1
class __a : """simple docstring""" def __init__( self : Any ,_UpperCamelCase : int ,_UpperCamelCase : List[Any] ) -> Union[str, Any]: '''simple docstring''' SCREAMING_SNAKE_CASE__ =name SCREAMING_SNAKE_CASE__ ...
588
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ), ...
588
1
'''simple docstring''' import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformer...
536
'''simple docstring''' from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ......
211
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a =logging.get_logger(__name__) a ="""▁""" a ={"""vocab_file""": """spiece.model"""...
709
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> Optional[...
337
0
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class _UpperCamelCase ( nn.Module ): '''simple docstring''' def __init__( self , _a = 16 , _a = 88 ...
394
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def lowerCAmelCase_ ( a : Tuple ): a__ = int(a ) ...
394
1
from __future__ import annotations import math import random from typing import Any class __magic_name__ : def __init__( self ) -> None: lowerCAmelCase_ = [] lowerCAmelCase_ = 0 lowerCAmelCase_ = 0 def __a ( self ) -> bool: ...
226
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ ...
226
1
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): # vision encoder if "img_encoder.pos_embed" in name: A_ : int = name.replace('''img_enc...
590
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor fr...
590
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :int =logging.get_logger(__name__) __snake_case :Any ={ 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class lowerC...
700
def lowerCamelCase_ ( lowerCAmelCase__ : list ) -> int: '''simple docstring''' if not grid or not grid[0]: raise TypeError('The grid does not contain the appropriate information' ) for cell_n in range(1 , len(grid[0] ) ): ...
224
0
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import logging logg...
10
from scipy.stats import spearmanr import datasets __A = '\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no correlation.\nPositive correlations imply that a...
484
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_te...
708
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput...
154
0
'''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, ) lowerCAmelCase_ : Union[...
489
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected" , [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10,...
489
1
'''simple docstring''' from __future__ import annotations def __a ( lowerCAmelCase__ : int ): a__ : List[str] = 2 a__ : Any = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(l...
340
'''simple docstring''' def __a ( lowerCAmelCase__ : list ): if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''' ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] a...
340
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available snake_case_ : List[str] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepen...
195
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.utils import ...
74
0
'''simple docstring''' # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v t...
574
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
574
1
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def snake_case_ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' _snake_case = Decimal # Check if the provided matrix has 2 rows and 2 columns # since th...
672
'''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 from sagemaker.hugg...
672
1
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' while a != 0: _lowerCAmelCase : Tuple = b % a, a return b def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ): '''...
705
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' if ( (cp >= 0X4E00 and cp <= 0X9FFF) or (cp >= 0...
16
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase ) class _UpperCAmelCase ( lowercase ): # `task` is not a ClassVar since we want it to be part of the `asdict` o...
631
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 transforme...
631
1
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int ) -> bool: '''simple docstring''' __lowerCamelCase : Any = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
704
"""simple docstring""" import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __A = 4 __A = 3 class _snake_case ( a__ ): pass def lowercase_ ...
366
0
'''simple docstring''' import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils impor...
90
'''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 ...
251
0
from pathlib import Path import fire from tqdm import tqdm def SCREAMING_SNAKE_CASE ( __lowerCAmelCase="ro" , __lowerCAmelCase="en" , __lowerCAmelCase="wmt16" , __lowerCAmelCase=None ) -> None: try: import datasets except (Module...
707
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageP...
208
0
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig, ...
242
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin ...
242
1
import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput UpperCAmelCase__ : Dict = logging.getLogger(__name__) if is_torch_tpu_av...
721
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller UpperCAmelCase__ : Optional[Any] = 3 def __lowercase ( _A ) -> int: print("""Generating primitive root of p""" ) while True: ...
446
0
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from...
22
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STA...
662
0
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def lowercase ( _a ) -> List[Any]: UpperCAmelCase_: List[Any] = [ "encoder.version", "decoder.version", "model.encoder.version", "model....
721
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( snake_case__ , unittest.Test...
306
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ : List[Any] = logging.get_logger(__name__) UpperCAmelCase__...
48
def UpperCamelCase( __UpperCamelCase : str ,__UpperCamelCase : str ): lowerCAmelCase_ : Any = len(__UpperCamelCase ) lowerCAmelCase_ : Optional[int] = [] for i in range(len(__UpperCamelCase ) - pat_len + 1 ): lowerCAmelCase_ : s...
171
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterM...
41
'''simple docstring''' import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) lowercase = logging.getLogger() ...
41
1
'''simple docstring''' from __future__ import annotations import math def __lowerCamelCase ( A__ ) -> List[Any]: """simple docstring""" if num <= 0: UpperCamelCase = F"""{num}: Invalid input, please enter a positive in...
430
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: fr...
143
0
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __lowerCamelCase : List[Any] = 1.0_5_4_5_7_1_8_1_7E-3_4 # unit of ℏ : J * s __lowerCamelCase : Optional[Any] = 3E8 # unit of c : m * s^...
717
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class A__ ( __snake_case ): def __init__( self , A_ , A_ = None , A_ = None , A_ = False , ...
38
0
import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self , a__): A__ = str(id_) A__ = None A__ = None A__ = [] A__ = {} # {vertex:dista...
632
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : Tuple = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeatureExtract...
297
0
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
145
'''simple docstring''' from __future__ import annotations _UpperCAmelCase : str = 10 def UpperCamelCase ( lowercase_ : list[int] ) -> list[int]: '''simple docstring''' lowercase =1 lowercase =max(lowercase_ ) while placement <= max_digit: # declare...
145
1
'''simple docstring''' from __future__ import annotations def A__ ( A_ , A_ ) -> list[str]: if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes: raise ValueError("partitions can not > number_of_b...
497
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __magic_name__ : List[Any] = { '''configuration_m2m_100''': ['''M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''M2M100Config''', ''...
497
1
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configu...
361
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simp...
361
1
def _a ( SCREAMING_SNAKE_CASE = 60_08_51_47_51_43 ): """simple docstring""" try: lowercase__ = int(SCREAMING_SNAKE_CASE ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ) if n <= 0: raise ValueError('''Parameter ...
43
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Accelerat...
547
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowercase_ : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
652
import functools def A__( __lowerCAmelCase , __lowerCAmelCase ): # Validation if not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or not all(isinstance(__lowerCAmelCase , __lowerCAmelCase ) for day in days ): raise ValueError('The parameter days should be a list of i...
652
1
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC a = parse(importlib.metadata.version("torch")) def _SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case ...
518
from graphs.minimum_spanning_tree_kruskal import kruskal def _SCREAMING_SNAKE_CASE ( ) -> Any: _UpperCAmelCase = 9 _UpperCAmelCase = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], ...
518
1
'''simple docstring''' 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 UpperCamelCase__( UpperCamelCase_...
717
def UpperCamelCase_ ( a_ , a_ ) ->int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCamelCase_ ( ) ->None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , ...
689
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase = {"""configuration_xlnet""": ["""XLNET_PRETRAIN...
5
'''simple docstring''' import os from datetime import datetime as dt from github import Github _lowercase = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ] def...
5
1
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def A ( A_ : Optional[int] )...
715
'''simple docstring''' import numpy as np class a : def __init__( self : Dict ): snake_case : List[str] = (0, 0) snake_case : Tuple = None snake_case : Union[str, Any] = 0 snake_case : Dict = ...
555
0
'''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-2.0...
78
import sys UpperCamelCase = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121...
66
0
'''simple docstring''' import re import string import numpy as np import datasets lowerCAmelCase__ : str = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" lowerCAmelCase__ : Option...
329
'''simple docstring''' lowerCAmelCase__ : Any = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase__ : int = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase__ : List[Any] = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: "Thursday", 5: "F...
329
1
from scipy.stats import spearmanr import datasets UpperCAmelCase__ : Dict = "\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no correlatio...
313
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CL...
313
1
from ....utils import logging _lowerCamelCase =logging.get_logger(__name__) class a_ ( lowerCamelCase_ ): """simple docstring""" def __init__( self : Optional[int] ,snake_case : int ,snake_case : Dict=None ,snake_case : Dict=2048 )...
252
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase =logging.get_logger(__name...
252
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
697
'''simple docstring''' import warnings from functools import wraps from typing import Callable def lowerCamelCase__ ( __lowerCamelCase : Callable ): '''simple docstring''' @wraps(__lowerCamelCase ) def _inner_fn(*__lowerCamelCase : int , **__lowerCamelCase ...
446
0
import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils imp...
718
snake_case = """Tobias Carryer""" from time import time class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : List[Any] , UpperCAmelCase_ : List[str] , UpperCAmelCase_ : Optional[int] , UpperCAmelCase_ : Any , UpperCAmelCase_...
488
0
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase : Any = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} tr...
690
"""simple docstring""" from __future__ import annotations def __snake_case ( UpperCamelCase__ ) -> list[int]: # This function is recursive """simple docstring""" A = len(UpperCamelCase__ ) # If the array contains only one element, we return it (it's th...
690
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase :str = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependen...
703
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokeniz...
26
0
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline UpperCAmelCase_ : Tuple = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argumen...
21
'''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_attent...
460
0
'''simple docstring''' import math class _UpperCamelCase : '''simple docstring''' def a__ ( self , a_ , a_ ) -> int: lowercase : Dict = 0.0 lowercase : Dict = 0.0 for i in range(len(a_ ) ): da += math.po...
425
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class ...
425
1
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline __A : Union[str, Any] = logging.get_logger(__name__) ...
575
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __A : Union[str, Any] = { 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_CON...
575
1
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 import Image...
446
import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProcessor fro...
446
1
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.c...
43
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 __SCREAMING_SNAKE_CA...
619
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def UpperCamelCase( lowercase_ ) -> List[Tuple[int, ...]]: '''simple do...
161
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.models....
161
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging __lowerCamelCase : Dict = logging....
416
def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: A__ : Tuple =1 for i in range(1, num + 1 ): fact *= i return fact def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: A__ : Optional[Any] =0 while number >...
416
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase : int = logging.get_logger(__name__) UpperCamelCase : Union[str, Any] ...
293
"""simple docstring""" import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder UpperCamelCase : Union[str, Any] = "__DUMMY_TRANSFORMERS_USER__" UpperCamelCase : List[Any] = "Dum...
293
1
'''simple docstring''' import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder A__ : List[Any] = """__DUMMY_TRANSFORMERS_USER__""" A__ : Optional[int] = """Dummy User""" A__ : Li...
13
'''simple docstring''' 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_fi...
379
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging _A : List[A...
518
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva _A : List[Any] = """""" _A : Dict = """""" _A : Optional[Any] = """""" _A : Dict = 1 # (0 is vertical, 1 is horizontal) def __magic_name__ (...
518
1
"""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_tokenizat...
104
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_uti...
104
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tok...
700
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _a : Any= {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise O...
192
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 tests f...
29
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available A_ = { """configuration_gpt_neo""": ["""GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoConfig""", """GPTNeoOnnxConfig"""], } try: ...
29
1
from __future__ import annotations import typing from collections import Counter def _snake_case (__lowercase): UpperCamelCase_ = Counter() for base in range(1 , max_perimeter + 1): for perpendicular in range(__lowercase , max_perimeter + ...
714
def _snake_case (__lowercase = 1000): UpperCamelCase_ , UpperCamelCase_ = 1, 1 UpperCamelCase_ = 2 while True: UpperCamelCase_ = 0 UpperCamelCase_ = fa + fa UpperCamelCase_ , UpperCamelCase_ = f...
618
0
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class snake_case_ ( uni...
345
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor UpperCAmelCase_ = logging.get_logger(__name__) class __UpperCamelCase ( A__ ): def __init__( self , *_UpperCamelCase , **_UpperCamelCase ): ...
32
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTest...
713
"""simple docstring""" import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def _lowerCAmelCase(a : List[str] , a : str , a : Optional[int] ) -> ...
165
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _snake_case = { '''configuration_groupvit''': [ '''GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GroupViTConfig'...
580
"""simple docstring""" import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentPa...
453
0
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __A ( unittest.TestCase ): """simple docstr...
711
def __UpperCAmelCase( lowercase_ ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection _lowerCamelCase : Tuple = len(lowercase_ ) _lowerCamelCase : List[str]...
613
0
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
327
# Copyright (c) 2021-, NVIDIA CORPORATION. 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 ap...
327
1
from math import isqrt def __magic_name__( _A ): '''simple docstring''' UpperCamelCase__ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , _A , ...
721
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_de...
265
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase = {"""configuration_unispeech""": ["""UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_...
174
"""simple docstring""" from __future__ import annotations import collections import pprint from pathlib import Path def lowerCAmelCase_ ( snake_case_ : str ) ->str: return "".join(sorted(snake_case_ ) ) def lowerCAmelCase_ ( snake_case_ ...
174
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers...
627
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available __a = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotA...
627
1
"""simple docstring""" from functools import lru_cache @lru_cache def _lowerCamelCase( a ): if num < 0: raise ValueError("Number should not be negative." ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import doctest doctest.tes...
528
def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ , UpperCamelCase__ = " " ): UpperCamelCase__ : Optional[int] = [] UpperCamelCase__ : int = 0 for index, char in enumerate(UpperCamelCase__ ): if char == separator: split_wor...
285
0
"""simple docstring""" from __future__ import annotations def _A ( _a : int , _a : int ) -> str: """simple docstring""" if b == 0: return (1, 0) ((A) , (A)) = extended_euclid(_a , a % b ) ...
711
"""simple docstring""" 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 UpperCAmelCase =get_logger(__name__) UpperCAmelCase =R"\n Args:\n input_ids (`jnp.ndarray` of...
255
0
'''simple docstring''' import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase_ ...
442
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class SCREAMING_SNAKE_CASE ( tf.k...
442
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 lowerCamelCase :int = logging.get_logger(__name__) lowerC...
686
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowerCamelCase :List[str] = logging.get_logg...
686
1