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
def __a ( lowerCAmelCase_ : int ) -> int: '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 UpperCAmelCase_= 1 UpperCAmelCase_= 1 while repunit: UpperCAmelCase_= (10 * repunit + 1) % divisor re...
593
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) # TODO Update this __A = { '''facebook/esm-1b''': '''https://huggingface.co/facebook/esm-1b/re...
593
1
'''simple docstring''' import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config i...
720
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase )-> str | Literal[False]: __UpperCAmelCase = list(_lowerCAmelCase ) __UpperCAmelCase ...
617
0
from collections.abc import Generator from math import sin def _A ( _lowercase ) -> bytes: """simple docstring""" if len(_lowercase ) != 32: raise ValueError('Input must be of length 32' ) __UpperCamelCase = B'' for i in [3, 2, 1, 0]: ...
1
def a__ ( A__ = 5_0_0_0_0_0_0_0 ): SCREAMING_SNAKE_CASE_ : Union[str, Any] = set() SCREAMING_SNAKE_CASE_ : Optional[int] = int((limit - 2_4) ** (1 / 2) ) SCREAMING_SNAKE_CASE_ : Dict = set(range(3, prime_square_limit + 1, 2 ) ) ...
101
0
'''simple docstring''' import os def snake_case ( ) -> Optional[int]: """simple docstring""" with open(os.path.dirname(snake_case ) + '/p022_names.txt' ) as file: lowerCAmelCase = str(file.readlines()[0] ) lowerCAmelCase = names.replace('"' , '' )....
514
'''simple docstring''' def snake_case ( snake_case : str ) -> str: """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
514
1
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a__ ( __snake_case ): def __init__( self , UpperCAmelCase , UpperCAmelCase ) -> Tuple: super().__ini...
559
from manim import * class a__ ( __snake_case ): def __SCREAMING_SNAKE_CASE ( self ) -> Dict: __a = Rectangle(height=0.5 , width=0.5 ) __a = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) __a ...
559
1
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowercase ( A, unittest.TestCase ): '''simple docstring''' _A : i...
720
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
591
0
'''simple docstring''' import argparse from collections import defaultdict import yaml __UpperCAmelCase ="docs/source/en/_toctree.yml" def __lowerCAmelCase ( UpperCamelCase__ ) -> List[str]: __lowerCamelCase = defaultdict(UpperCamelCase__ ) for doc in...
546
'''simple docstring''' def __lowerCAmelCase ( ) -> Optional[Any]: __lowerCamelCase = 0 for i in range(1 , 10_01 ): total += i**i return str(UpperCamelCase__ )[-10:] if __name__ == "__main__": print(solution())
546
1
'''simple docstring''' from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_mode...
211
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ...
211
1
"""simple docstring""" import pprint import requests A_ = '''https://zenquotes.io/api''' def UpperCAmelCase__ (): """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def UpperCAmelCase__ (): """simple docstring""" ...
609
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } cla...
609
1
'''simple docstring''' 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 PatchingSp...
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
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ = None ) -> str: '''simple docstring''' if version.parse(hfh.__version...
472
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[list[float]] ) -> list[list[float]]: __lowerCAmelCase : list[list[float]] = [] for data in source_data: for i, el in enumerate(SCREAMING_SNAKE_CASE ): if len(SCREAMING_SNAKE_CASE ) < i + 1: da...
504
0
'''simple docstring''' def _A (lowerCAmelCase__ :int = 2_00 ) -> int: '''simple docstring''' _a = [1, 2, 5, 10, 20, 50, 1_00, 2_00] _a = [0] * (pence + 1) _a = 1 # base case: 1 way to make 0 pence for co...
532
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers....
532
1
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __SCREAMING_SNAKE_CASE( a_ ): def __init__( self: List[Any] , UpperCamelCase: int , UpperCamelCase: Dict , ...
328
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : str = { """facebook/timesformer""": """https://huggingface.co/facebook/timesformer/resolve/main/config.jso...
328
1
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowercase ( SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE_...
705
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor...
198
0
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 lowerCAmelCase__ ( __magic_name__ ): '''si...
184
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class lowerCAmelCase__ ( __magic_name__ ): ''...
184
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel...
121
"""simple docstring""" import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __a ( _lowercase ...
121
1
import random def A ( lowercase__ : Dict , lowercase__ : str , lowercase__ : Optional[Any] ) -> int: UpperCamelCase__ :List[Any] = a[left_index] UpperCamelCase__ :Dict = left_index + 1 for j in range(left_index + 1 , lowercase__ ): if a[j] < pivot: UpperCamelC...
45
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class lowerCAmelCase_ ( lowercase ): """simple docstring""" de...
45
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def _A ( _UpperCamelCase , _UpperCamelCase=None ): _UpperCAmelCase : Optional[int] = None if token is not None: _UpperCAmelCase : ...
416
import baseaa def _A ( _UpperCamelCase ): return baseaa.baaencode(string.encode('''utf-8''' ) ) def _A ( _UpperCamelCase ): return baseaa.baadecode(_UpperCamelCase ).decode('''utf-8''' ) if __name__ == "__main__": UpperCAmelCase__ : Union[str, Any] = 'Hello World!' ...
416
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ : Optional[int] = { """configuration_trajectory_transformer""": [ """TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHI...
435
'''simple docstring''' def __A ( UpperCAmelCase ,UpperCAmelCase ) -> str: '''simple docstring''' _UpperCamelCase : str = [0 for i in range(r + 1 )] # nc0 = 1 _UpperCamelCase : List[Any] = 1 for i in ra...
435
1
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distributed...
704
import math from numpy import inf from scipy.integrate import quad def __lowerCAmelCase ( __lowerCamelCase : float ) -> float: if num <= 0: raise ValueError("""math domain error""" ) return quad(__lowerCamelCase , 0 , __lowerCamelCase , args=(__lowerCamelCa...
456
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu...
603
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): ...
650
0
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int , __lowerCamelCase: int ): '''simple docstring''' return number | (1 << position) def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int , __lowerCamelCase: int ): '''simple docstring''' return number & ~...
709
from __future__ import annotations from cmath import sqrt def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int , __lowerCamelCase: int , __lowerCamelCase: int ): '''simple docstring''' if a == 0: raise ValueError("Coefficient 'a' must not be zero." ) lowercase_ = b ...
601
0
__a : Any = 8.3_14_45_98 def __magic_name__ ( lowercase_ , lowercase_ ) -> float: '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("...
606
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_...
459
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met ...
486
from math import factorial UpperCamelCase__ : dict[str, int] = {str(digit): factorial(digit) for digit in range(10)} def A_( A ): if not isinstance(A , A ): raise TypeError("""Parameter number must be int""" ) if number < 0: raise ValueError("""Parameter nu...
486
1
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": _lowerCAmelCase = '''%20'''.join(argv[1:]) if len(argv) > 1 else ...
259
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute_m...
686
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAM...
701
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 HfArgumentParser, Trai...
311
0
import inspect import unittest from transformers import ViTMSNConfig 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_configuration_common import ConfigTester from ....
16
"""simple docstring""" def __UpperCamelCase ( SCREAMING_SNAKE_CASE ) -> str: """simple docstring""" if not all(char in "01" for char in bin_string ): raise ValueError("Non-binary value was passed to the function" ) if not bin_string: raise ...
163
0
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __lowerCAmelCase = { '''gwf...
712
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor __lowerCAmelCase = logging.get_logger(__name__) class __a ( __UpperCamelCase ): def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__...
335
0
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.util...
94
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts...
513
0
import requests def A__ ( lowerCamelCase , lowerCamelCase ) -> None: UpperCamelCase_: Union[str, Any] = {"""Content-Type""": """application/json"""} UpperCamelCase_: List[Any] = requests.post(lowerCamelCase , json={"""text""": message_body} ,...
670
from manim import * class _UpperCamelCase ( _A ): '''simple docstring''' def lowerCAmelCase__ ( self : int ): UpperCamelCase_: Dict = Rectangle(height=0.5 , width=0.5 ) UpperCamelCase_: Dict = Rectangle(height=0.46 ,...
670
1
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging A ...
125
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_o...
328
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 # ...
47
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
47
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A_ : Dict = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GraphormerConfig'], } try: if...
57
"""simple docstring""" from itertools import count def UpperCamelCase__ ( lowercase__ : int = 50 ): snake_case : List[str] = [1] * min_block_length for n in count(lowercase__ ): fill_count_functions.append(1 ) for block_length in range(lowercase__ , ...
134
0
'''simple docstring''' from itertools import product def UpperCamelCase ( lowercase_ : List[Any] , lowercase_ : int ) -> list[int]: '''simple docstring''' lowercase =sides_number lowercase =max_face_number * dice_number lowercase =[0] * (max_tot...
720
'''simple docstring''' from typing import Dict, Iterable, Optional, 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, to_pil_image from ...image_utils import ( IM...
145
0
"""simple docstring""" import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transf...
673
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyN...
673
1
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 _snake...
54
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( snake_case_ ): # A local function to see if a dot lands in the circle. def is_in_circle(snake_case_,snake_case_ ) -> bool: _A ...
54
1
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_ve...
597
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline SCREAMING_SNAKE_CASE_ = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=F...
597
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import (...
710
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging a__ : int = logging.get_logger(__name__) a__ : Tuple = {"vocab_file": "vocab.txt"} a__ : int ...
642
0
"""simple docstring""" from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def snake_case_ ( ): '''simple docstring''' _lowerCamelCase , _lowerCamelCase : Optional[int] = 9, 14 # noqa: F84...
83
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_albert im...
197
0
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 SPIECE_UNDERLINE, logging _snake_case : List[Any] = logging.get_lo...
421
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def a_ ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.raises(lowerCAme...
421
1
from __future__ import annotations def __UpperCamelCase ( lowercase__ : list ) -> list: '''simple docstring''' if len(lowercase__ ) == 0: return [] lowerCAmelCase_ , lowerCAmelCase_ : Optional[int] = min(lowercase__ ), max(lowercase__...
600
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeli...
600
1
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 __UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' def ...
702
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets UpperCamelCase_ = "\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n and S...
599
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 from ...test_t...
120
def A ( _lowerCamelCase ): '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): _lowerCAmelCase : Union[str, Any] = F"Input value of [number={number}] must be an integer" raise TypeError(_lowerC...
500
0
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCAmelCase__ : Union[str, Any] =[ # (stable-diffusion, HF Diffusers) ('''time_embed.0.weight''', '''time_embe...
269
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
269
1
'''simple docstring''' import re from filelock import FileLock try: import nltk _SCREAMING_SNAKE_CASE : Optional[int] = True except (ImportError, ModuleNotFoundError): _SCREAMING_SNAKE_CASE : Optional[Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: ...
400
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : int = ...
400
1
'''simple docstring''' import inspect import unittest from transformers import ConvNextConfig 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_backbone_common import Backbone...
700
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_g...
609
0
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, lo...
82
"""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 = logging.get_logger(__name__) lower...
82
1
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy SCREAMING_SNAKE_CASE__ = logging.get_logger(__name...
711
import torch from transformers import AutoModel class _UpperCamelCase( torch.nn.Module ): def __init__( self : str , SCREAMING_SNAKE_CASE__ : Tuple="sayef/fsner-bert-base-uncased" ): '''simple docstring''' super(SCREAMING_SNAK...
577
0
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) __snake_case = models.Sequential() # Step 1 - Convo...
386
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __snake_case = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.m...
386
1
"""simple docstring""" def _snake_case ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: ...
505
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer a =...
505
1
"""simple docstring""" import os import pytest from transformers.dynamic_module_utils import get_imports a ='\nimport os\n' a ='\ndef foo():\n import os\n return False\n' a ='\ndef foo():\n def bar():\n if True:\n import os\n return False\n return bar()\n' a ='\...
530
"""simple docstring""" import os from distutils.util import strtobool def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase ) -> Union[str, Any]: '''simple docstring''' for e in env_keys: lowerCamelCase__ =int(os.environ.get(__lowerCAmelCase , ...
530
1
def a_ ( lowerCAmelCase_ : Tuple ): __lowerCAmelCase = [] __lowerCAmelCase = set({'(', '[', '{'} ) __lowerCAmelCase = set({')', ']', '}'} ) __lowerCAmelCase = {'{': '}', '[': ']', '(': ')'} for i in range(len(__A ) ): if...
701
_snake_case : List[Any] = '0.18.2' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_libr...
421
0
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_sp...
561
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin if...
140
0
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file, a...
448
__lowerCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } __lowerCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A__ ( ...
448
1
"""simple docstring""" class __UpperCAmelCase( __lowercase ): """simple docstring""" pass class __UpperCAmelCase( __lowercase ): """simple docstring""" pass class __UpperCAmelCase: ...
218
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class UpperCAmelCase_ : def __init__( self : Union[str, Any] , UpperCAmelCase__ : list[tuple[float, float]] ) -> Optional[int]: lowerC...
133
0
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __UpperCamelCase ( lo...
712
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
326
0
def A__ (snake_case : int ) -> bool: return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number or not...''') a__ = int(input('''Enter number: ''')...
279
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table, ...
279
1
from ..utils import DummyObject, requires_backends class A_ ( metaclass=__lowerCamelCase ): '''simple docstring''' _UpperCamelCase : Optional[int] = ["""keras_nlp"""] def __init__( self , *snake_case , **snake_case ): requires_backends(self , ['keras_nlp'] )
565
from math import factorial UpperCAmelCase = {str(d): factorial(d) for d in range(10)} def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): return sum(DIGIT_FACTORIAL[d] for d in str(__SCREAMING_SNAKE_CASE ) ) def UpperCAmelCase_ ( ): lowercase = ...
565
1
from __future__ import annotations def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' lowerCamelCase_ : Any = sorted(numsa + numsa) lowerCamelCase_ ,lowerCamelCase_ : List[str] = divmod(len(lowe...
250
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torc...
250
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
702
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "bert-base-uncased": "https://huggingface.co/bert-base-uncased/resolve/main/config.js...
279
0
'''simple docstring''' import random def a_ ( __snake_case : int , __snake_case : Tuple , __snake_case : List[str] ) -> Tuple: """simple docstring""" lowerCamelCase_ =a[left_index] lowerCamelCase_ =left_index + 1 for j in range(left_...
676
def A__ ( lowercase: Any, lowercase: List[Any], lowercase: List[Any]=False ) -> Dict: if isinstance(lowercase, lowercase ) and isinstance(lowercase, lowercase ): A : int =len(set_a.intersection(lowercase ) ) if alternati...
305
0
"""simple docstring""" from collections.abc import Sequence def _A ( _a : Sequence[float] , _a : bool = False ): """simple docstring""" if not arr: return 0 A = 0 if allow_empty_subarrays else float("""-inf""" ...
255
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCamelCase__ ( unittest.TestCase ): '''simple d...
255
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { "tanreinama/GPTSAN-2.8B-spout_is_uniform": ( "https://huggingface.co/tanreinama...
21
from pathlib import Path import fire from tqdm import tqdm def lowerCAmelCase_ ( lowerCamelCase="ro" , lowerCamelCase="en" , lowerCamelCase="wmt16" , lowerCamelCase=None ): try: import datasets except (ModuleNotFoundError, ImportError): raise I...
21
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
712
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ra...
688
0
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict SCREAMING_SNAKE_CASE_ = namedtuple( '_TestCom...
34
import json import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
108
0
"""simple docstring""" from itertools import count def _a ( _snake_case = 50 ): """simple docstring""" UpperCAmelCase = [1] * min_block_length for n in count(a_ ): fill_count_functions.append(1 ) for block_length in range(a_...
712
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common imp...
74
0
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets ...
247
"""simple docstring""" import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils...
247
1
from __future__ import annotations def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase , __UpperCamelCase :int = position __UpperCamelCase :List[str] = [ (y + 1, x + 2), (y - 1, x + ...
712
from __future__ import annotations import bisect def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = 0 , SCREAMING_SNAKE_CASE = -1 ): '''simple docstring''' if hi < 0: __UpperCamelCase :str = len(SCREAMING_SNAK...
452
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase_ = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], """toke...
92
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''RUCAIBox/mvp''': '''https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json''', } class __SCREAMING_SNA...
125
0
'''simple docstring''' def lowerCAmelCase__ ( a_ : str = 2_0_0 ) -> int: UpperCAmelCase__ : Union[str, Any] = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] UpperCAmelCase__ : int = [0] * (pence + 1) UpperCAmelCase__ : Optional[int] ...
719
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __UpperCAmelCase ...
599
0
"""simple docstring""" import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __lowerCAmelCase ( ...
391
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrateg...
391
1
"""simple docstring""" import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met c...
370
"""simple docstring""" def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__ = 10, SCREAMING_SNAKE_CASE__ = 1_000, SCREAMING_SNAKE_CASE__ = True ) -> int: assert ( isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ) and isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ...
370
1
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common ...
19
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A: Dict = { "configuration_whisper": ["WHISPER_PRETRAINED_CONFI...
160
0
import numpy as np def lowercase ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : Optional[Any] = 1e-1_2 , SCREAMING_SNAKE_CASE__ : Dict = 100 , ) -> Union[str, Any]: assert np.shape(A...
710
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_ca...
198
0
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 _lowerCamelCase : str = logging.get_logger(__name__) _lowerCamelCase : Tuple = ...
403
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer _snake_case : Tuple = ...
22
0
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..uti...
710
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCamelCase__ : Any = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/saya...
385
0
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobert...
67
"""simple docstring""" __lowercase : Union[str, Any] = 8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def lowerCamelCase_ ( _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ): if moles < 0 or kelvin < 0 or volume < 0: raise V...
142
0
'''simple docstring''' import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __UpperCamelCase ...
270
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Optional[int] = { """configur...
270
1
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ) -> np.array: lowerCamelCase_ = f'''{sampling_rate}''' lowerCamelCase_ = ...
42
'''simple docstring''' from math import sqrt def __UpperCAmelCase ( lowerCamelCase_ = 1_000_000) -> int: UpperCamelCase__ : int = 0 UpperCamelCase__ : int = 0 UpperCamelCase__ : int while num_cuboids <= l...
596
0
"""simple docstring""" from math import sqrt def _snake_case ( UpperCamelCase : Dict ): UpperCAmelCase : Optional[int] = 0 for i in range(1 , int(sqrt(__UpperCamelCase ) + 1 ) ): if n % i == 0 and i != sqrt(__UpperCamelCase ): total += i + n // i elif i == sqrt(__UpperCamelCase )...
713
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer A: List[An...
359
0
from math import pi, sqrt, tan def UpperCamelCase ( _A : float )-> float: """simple docstring""" if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values" ) return 6 * side_length**2 def UpperCamelCase ( _A : fl...
491
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class UpperCam...
491
1
'''simple docstring''' import unittest import numpy as np def snake_case__ ( _A: np.ndarray , _A: np.ndarray , _A: np.ndarray , _A: np.ndarray | None = None , ) -> np.ndarray: '''simple docstring''' lowerCAmelCase = np.sh...
605
'''simple docstring''' from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def snake_case__ ( _A: np.ndarray , _A: np.ndarray , _A: np.ndarray , _A: int , _A: int ) -> np.ndarray: '''simple do...
605
1
"""simple docstring""" import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(__SCREAMING_S...
572
"""simple docstring""" import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness lowercase_ : str = '''\ @misc{chen2021evaluat...
572
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...
254
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowerCamelCase ( _snake_case ): def wrapper(*_snake_case ,**_snake_case ): UpperCAmelCase__ : str ...
254
1
'''simple docstring''' def UpperCamelCase_ ( A__ , A__ ): return int((input_a, input_a).count(0 ) == 0 ) def UpperCamelCase_ ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0 ) == 0 assert and_...
263
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fas...
458
0
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ....
639
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INP...
639
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logge...
344
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as Proph...
344
1
import numpy as np def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : Tuple , __UpperCamelCase : List[str] , __UpperCamelCase : Dict , __UpperCamelCase : int , __UpperCamelCase : str ) -> Any: """simple docstring""" SCREAMIN...
379
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCamelCase : Any ...
379
1
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem lowercase__ : Union[str, Any] = importlib.util.find_s...
8
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowerCAmelCase__ = """\ """ lowerCAmelCase__ = """ Perplexity (PPL) is one of the most common metrics for evaluating lang...
514
0
'''simple docstring''' import numpy as np def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): lowerCamelCase_ = int(np.ceil((x_end - xa) / h ) ) lowerCamelCase_ = np.ze...
708
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowerCamelCase_ ( lowerCamelCase__ ): if "cls_token" in name: lowerCamelCase_ = name.replace("cls_token" , "vit.em...
313
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor __snake_case : List[str] =logging.get_logger(__name__) class lowerCamelCase__ ( __lowerCamelCase): '''simple docstring''' def __init__(self ,*__lowerCamelCas...
647
from itertools import product def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ = sides_number A_ = max_face_number * dice_number A_ = [0] * (max_total + 1) A_ ...
203
0
'''simple docstring''' import os from collections import deque import torch from torch.utils.data import Dataset class a ( __magic_name__ ): def __init__( self : Union[str, Any], SCREAMING_SNAKE_CASE_ : str="", SCREAMING_SNAKE_CASE_ : str="train" ): asse...
703
'''simple docstring''' import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForCond...
555
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=lowercase_ ) class lowerCAmelCase_ ( lowercase_ ): """simple docstring""" ...
582
_snake_case = """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""" def _A ( __magic_name__ ): # Make sure the supplied data is a bytes-like object if not isinstance(__magic_name__ , __magic_name__ ): lowercase__ = f'''a bytes-like object is re...
655
0
from __future__ import annotations from functools import lru_cache from math import ceil snake_case : Dict = 1_0_0 snake_case : Union[str, Any] = set(range(3, NUM_PRIMES, 2)) primes.add(2) snake_case : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in pri...
182
def snake_case__ ( __lowercase ) -> int: """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 A__ : Tuple = 1 A__ : Union[str, Any] = 1 while repunit: A__ : Union[str, Any] ...
182
1
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def lowerCAmelCase_ ( __UpperCAmelCase: Optional[Any] ) -> str: UpperCamelCase__ : Optional[int] = [ '''encoder...
253
import pytest UpperCAmelCase_ = '__dummy_dataset1__' UpperCAmelCase_ = '\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-train.jsonl", "validation": REP...
253
1
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenizat...
4
'''simple docstring''' import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Bert...
4
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ ={ "configuration_efficientformer": [ "EFFICIENTFORMER_PRE...
616
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.mod...
616
1
'''simple docstring''' import sys __SCREAMING_SNAKE_CASE :Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''125406987471585238630507156932909632952...
119
'''simple docstring''' import sys from collections import defaultdict class A_ : def __init__( self : Dict ): _UpperCAmelCase = [] def lowercase ( self : Union[str, Any] , snake_case_ : List[str] ): return self.node_positi...
119
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : Union[str, Any] = logging.get_logger(__name__) __a : Dict = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _UpperCamelCase ( _UpperCAmelCase ): ...
534
def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" __lowercase = len(lowercase ) __lowercase = len(lowercase ) __lowercase = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] __lowercase ...
534
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { '''configuration_chinese_clip''': [ '''CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Chine...
544
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_blenderbot''': [ ...
544
1