code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase__: Op...
23
"""simple docstring""" 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_ ): """simple doc...
224
0
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) -> list[int]: '''simple docstring''' lowerCAmelCase : Any = int(_UpperCAmelCase ) # Initialize Result lowerCAmelCase : Dict = [] # Traverse through all denomination fo...
323
from collections.abc import Sequence def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) -> float: '''simple docstring''' return sum(c * (x**i) for i, c in enumerate(_UpperCAmelCase ) ) def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) ...
323
1
import re def UpperCAmelCase ( lowercase ): """simple docstring""" return [char.split() for char in re.split(r'''[^ a-z A-Z 0-9 \s]''' , str_ )] def UpperCAmelCase ( lowercase ): """simple docstring""" __lowercase = ...
210
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time __a : List[str] = Lock() def UpperCAmelCase ( lowercase , lowercase , lowercase , lowercase , lowercase , lowercase ,...
210
1
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interl...
285
def _snake_case( SCREAMING_SNAKE_CASE__ ) -> int: assert ( isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) and number_of_steps > 0 ), f"number_of_steps needs to be positive integer, your input {number_of_steps}" if number_of_steps == 1: re...
285
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(): ...
125
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case_ : Union[str, Any] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix...
125
1
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.command...
38
"""simple docstring""" 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 impo...
38
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
87
"""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 __UpperCAm...
84
0
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_tim...
267
import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> Tuple: """simple docstring""" if ( (cp >= 0X4E00 and cp <= 0X9FFF) or (cp >= 0X3...
267
1
"""simple docstring""" import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , set() ) @pyte...
153
import math import random def lowerCAmelCase_ ( __A, __A = False ) -> float: '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value UpperCamelCase__ = 0.0_...
65
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : Optional[Any] = {'''configuration_deit''': ['''DEIT_PRETRAINED_CON...
369
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device SCREAMING_SNAKE_CASE : List[str] = False class __lowerCamelCase...
317
0
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline UpperCamelCase = argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) parser.add_argument("""--dpm""", action="""stor...
186
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase = { """configuration_roberta""": ["""ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP""", "...
186
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : List[Any] = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], } try: if not is_torch_av...
130
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Union[str, Any] = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # See ...
130
1
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_tenso...
284
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_...
284
1
"""simple docstring""" from __future__ import annotations def lowercase__( __SCREAMING_SNAKE_CASE : Union[str, Any] ): return [ord(_lowerCAmelCase ) - 96 for elem in plain] def lowercase__( __SCREAMING_SNAKE_CASE : Tuple ): return "".join(chr(elem + 96 ) for ...
371
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_att...
321
0
'''simple docstring''' def _lowerCamelCase ( lowercase : list[int] , lowercase : list[int] ) -> None: _a = len(lowercase ) print("The following activities are selected:" ) # The first activity is always selected _a = 0 print...
63
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _UpperCAmelCase : Optional[int] ="""src/transformers""" _Up...
262
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCamelCase : Dict = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotA...
114
'''simple docstring''' from math import factorial def _lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : float ) -> float: """simple docstring""" if successes > trials: raise ValueError('successes mu...
114
1
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> int: '''simple docstring''' assert x is not None assert y is not None UpperCamelCase = len(UpperCamelCase_ ) UpperCamelCase = len(UpperCamelCase_ ) # declaring the array for storing the dp values Uppe...
343
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY_UN...
343
1
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaToken...
348
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__magic_name__ ) class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" ...
348
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
126
"""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: ...
126
1
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor __lowerCAmelCase = logging.get_logger(__name__) class __a ( _UpperCAmelCase ): def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__ ) -> List[Any...
355
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_inpu...
288
0
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import Heun...
132
"""simple docstring""" from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_...
132
1
"""simple docstring""" import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestM...
166
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() _A = ...
166
1
"""simple docstring""" import logging from transformers import PretrainedConfig lowerCAmelCase = logging.getLogger(__name__) lowerCAmelCase = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/reso...
126
"""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__) lowerCAmel...
126
1
import random def _lowercase ( _UpperCAmelCase , _UpperCAmelCase ) -> tuple: lowerCamelCase , lowerCamelCase , lowerCamelCase =[], [], [] for element in data: if element < pivot: less.append(_UpperCAmelCase ) elif element > pivot: ...
262
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
262
1
import argparse import os import re import packaging.version lowerCAmelCase__ = """examples/""" lowerCAmelCase__ = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(R"""^__vers...
68
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultis...
265
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
350
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor ...
313
0
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline UpperCAmelCase__ = datasets.utils.logging.get_logger(_...
5
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch_available(): raise Opti...
5
1
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Path from urlli...
180
import math import sys def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: if number != int(__UpperCamelCase): raise ValueError("the value of input must be a natural number") if number < 0: raise ValueError("the value of input must not be a negative number") ...
180
1
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate UpperCamelCase_ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('''''', '''|''', '''|'''), ...
345
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def lowercase (SCREAMING_SNAKE_CASE_ : Callable[[int | float], int | float] , SCREAMING_SNAKE_CASE_ : int | float , SCREAMING_SNAKE_CASE_ : int | float , SCREAMING_SNAKE_CASE_ :...
113
0
'''simple docstring''' def __A ( lowerCAmelCase_ , lowerCAmelCase_ ): if digit_amount > 0: return round(number - int(lowerCAmelCase__ ) , lowerCAmelCase__ ) return number - int(lowerCAmelCase__ ) if __name__ == "__main__": print(decimal_isolate(1.5_3, 0)) print(decimal_isolate(3_5.3...
359
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def __A ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ = None , l...
170
0
'''simple docstring''' from __future__ import annotations import math def lowercase__ ( __UpperCamelCase )-> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
321
import string def UpperCamelCase (lowercase_: str ) -> None: for key in range(len(string.ascii_uppercase ) ): A__ : Dict = """""" for symbol in message: if symbol in string.ascii_uppercase: A__ : Dict = string.ascii_uppercase.find(lowercase...
192
0
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, ...
240
'''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_bert import BertTokenizer __UpperCAmelCase :Dict = log...
240
1
'''simple docstring''' from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": UpperCAmelCase = input('''Enter image url: ''').strip() print(F'''Downloading image from {url} ...''') UpperCAmelCase = BeautifulSoup(requests.get(u...
141
'''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...
141
1
"""simple docstring""" import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTe...
268
"""simple docstring""" 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 SCREAMING_SNAKE_CASE__:Tu...
268
1
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data i...
109
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A: List[str] = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CL...
109
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
24
"""simple docstring""" def lowercase ( _snake_case : int ) ->str: """simple docstring""" if number > 0: raise ValueError('''input must be a negative integer''' ) __snake_case : Any = len(bin(_snake_case )[3:] ) __snake_case : List[Any] ...
24
1
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ ...
289
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class a : def __init__( self : Union[str, Any] ): _UpperCAmelCase = {} def lowerCAmelCase_ ( self : Optional[int] , __lowerCAmelCase ...
289
1
__UpperCAmelCase = [ (10_00, "M"), (9_00, "CM"), (5_00, "D"), (4_00, "CD"), (1_00, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = {'''...
257
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxMTaF...
257
1
def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> int: '''simple docstring''' UpperCAmelCase = len(_UpperCAmelCase ) UpperCAmelCase = [[0] * n for i in range(_UpperCAmelCase )] for i in range(_UpperCAmelCase ): Up...
273
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import ...
226
0
"""simple docstring""" import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def SCREAMI...
2
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Config...
2
1
import json import sys def UpperCAmelCase ( a_ , a_ ) -> Dict: """simple docstring""" with open(lowerCAmelCase__ , encoding="utf-8" ) as f: __A = json.load(lowerCAmelCase__ ) __A = ['''<details>''', '''<summary>Show updated benchmarks!</summary>'...
15
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> int: UpperCAmelCase__ : Tuple = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def a__ ( lowerCAmelCase__ = 1_00 ) -> int: Up...
181
0
from __future__ import annotations def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> set[str]: lowerCAmelCase__ : Optional[Any] = set(SCREAMING_SNAKE_CASE_ ), [start] while stack: lowerCAmelCase__ : List[Any] = stac...
370
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTeste...
307
0
"""simple docstring""" from __future__ import annotations import math def lowerCamelCase ( _UpperCamelCase : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or numbe...
115
"""simple docstring""" from importlib import import_module from .logging import get_logger UpperCAmelCase : Any = get_logger(__name__) class lowerCamelCase__ : """simple docstring""" def __init__( self : Optional[int] , UpperCamelCase : List[A...
115
1
'''simple docstring''' import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchE...
160
'''simple docstring''' import torch from transformers import AutoModel class __UpperCAmelCase ( torch.nn.Module ): def __init__( self , lowerCAmelCase_="sayef/fsner-bert-base-uncased" ): """simple docstring""" super(lowerCAmelCase_ , self )....
160
1
def _snake_case ( lowerCAmelCase : Any ): """simple docstring""" return " ".join( "".join(word[::-1] ) if len(lowerCAmelCase__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('''Hey wollef sroir...
18
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransformer,...
101
0
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): lowercase__ = n - k # Calculate C(n,k) for i in range(SCREAMING_SNAKE...
93
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_seri...
93
1
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class _a : """simple docstring""" def __init__( self : Optional[Any] )->Any: _UpperCAmelCase = {} def lowercase...
260
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __A : int = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def lowercase ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE ...
260
1
"""simple docstring""" def _lowerCAmelCase ( UpperCAmelCase : List[str] ): '''simple docstring''' stooge(__lowerCAmelCase , 0 , len(__lowerCAmelCase ) - 1 ) return arr def _lowerCAmelCase ( UpperCAmelCase : List[Any] , UpperCAmel...
350
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB 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/li...
157
0
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : int = 1000 ) ->int: _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 1, 1 _SCREAMING_SNAKE_CASE = [] for i in range(1 , n + 1 ): _SCREAMING_SNAKE_CASE = prev_n...
58
'''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 OptionalDep...
58
1
'''simple docstring''' 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 ...
352
'''simple docstring''' import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class a__( tf.keras.optimizers.schedules.LearningRateSchedu...
96
0
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase = 10 , UpperCAmelCase = 22 ) ->int: """simple docstring""" a_ = range(1 , UpperCAmelCase ) a_ = range(1 , UpperCAmelCase ) return sum( 1 for power in powers for base in bases ...
243
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
243
1
'''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 __lowerCAm...
5
'''simple docstring''' def UpperCAmelCase_ (__a : str ): """simple docstring""" _a : List[Any] = 0 # if input_string is "aba" than new_input_string become "a|b|a" _a : Optional[int] = '' _a : List[str] = '' # append each c...
5
1
'''simple docstring''' import baseaa def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" return baseaa.baaencode(string.encode("""utf-8""" ) ) def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" ...
70
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_ver...
176
0
def a_ ( __lowercase : int , __lowercase : float , __lowercase : float ) -> float: return round(float(moles / volume ) * nfactor ) def a_ ( __lowercase : float , __lowercase : float , __lowercase : float ) -> float: return round(...
130
def a_ ( __lowercase : int = 50_000_000 ) -> int: _snake_case = set() _snake_case = int((limit - 24) ** (1 / 2) ) _snake_case = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ...
130
1
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _a ( unittest.TestCase ): def __snake_case (self ) -> None: UpperCAmelCase_: Union[str, Any] =...
147
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a : List[str] = { 'configuration_vision_encoder_decoder': ['VisionEncoderDecoderConfig', 'VisionE...
147
1
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase : int = logging.get_logger(__name__) lowerCamelCase : List[str] = {'vocab_file': 'sentencepiece...
356
def SCREAMING_SNAKE_CASE__ ( ) -> Dict: snake_case : Optional[int] = [] snake_case : Tuple = 1 while len(lowercase ) < 1E6: constant.append(str(lowercase ) ) i += 1 snake_case : int = """""".join(lowercase ) ...
176
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable __SCREAMING_SNAKE_CASE :Union[str, Any] = { '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_A...
22
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/microsoft/unisp...
320
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil lowercase =100 lowercase =set(range(3, NUM_PRIMES, 2)) primes.add(2) lowercase =42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: continue primes.d...
242
'''simple docstring''' from __future__ import annotations import bisect def lowerCamelCase__ ( __lowerCamelCase : list[int] , __lowerCamelCase : int , __lowerCamelCase : int = 0 , __lowerCamelCase : int = -1 ): '''simple docstring''' if hi < ...
242
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = {'''configuration_reformer''': ['''REFORMER_PRETRAINED_CONFIG_ARCHI...
69
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration snake_case__ : Union[str, Any] = 500000 snake_case__ , snake_case__ : Optional[Any] = os.path.split(...
117
0
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __a ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_...
354
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _a = logging.get_logge...
23
0
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : def __init__( self : Dict , __snake_case : int ) -> Tuple: _lowerCAmelCase = order # a_{0} ... a_{k} _lowerC...
70
def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> int: '''simple docstring''' def update_area_of_max_square(UpperCamelCase_ , UpperCamelCase_ ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 SCREAMING_SN...
176
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCamelCase ( metaclass=lowercase ): UpperCAmelCase : Any = ["""onnx"""] def __init__(self : Union[str, Any] , *_A : int , **_A : Tuple) -> Union[...
95
"""simple docstring""" import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, D...
95
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _SCREAMING_SNAKE_CASE ( unittest.TestCase , _a ): def _A ( self : Union[str, Any] ): UpperCamelCase :Union[str, Any] = load_tool("""text-classification...
38
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput lowercase_ : str = 'scheduler_config.json' class __lowerCAmelCase ( UpperCAmelCase__ ): snake_case_ : List...
133
0
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase ) -> Optional[Any]: snake_case : Tuple = AutoConfig.from_pretrained(__lowerCam...
351
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def SCREAMING_SNAKE_CASE__ ( ) -> List[Any]: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ...
176
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...
238
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils....
238
1
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { """kakaobrain/align-base""": """http...
35
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, ) lowercase = { """configuration_xlm_roberta""...
35
1
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_vae_attention_paths, ren...
130
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models.ba...
130
1
import requests _A = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : str ): # fetching a list of articles in json format __UpperCamelCase =requests.get(_NEWS_API + bbc_news_api_key ).json() #...
117
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer _A = logging.get_logger(__name__) _A = {'vocab_file': 'vocab.txt', 'token...
117
1
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 .tokenization_blenderbot import Blend...
328
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_op...
293
0
"""simple docstring""" from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, requir...
230
"""simple docstring""" from typing import Any class UpperCAmelCase_ : def __init__( self : Optional[Any] , snake_case_ : Any ) -> List[str]: '''simple docstring''' A__ = data A__ = None def __repr__( self : Optional[int] ...
230
1
"""simple docstring""" import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration a :List[str] = 50_000 a :Union[str, Any] = 5_000 a ,a :Dict = os.path.split(__file__) a :Dict = os.path.join(RESULTS_BASEPATH, "resu...
132
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
11
0
'''simple docstring''' import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transf...
229
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _lowercase = datasets.logging.get_logger(__name__) _lowercase = """\ @InProceedings{moosavi2019minimum, author ...
229
1
"""simple docstring""" from bisect import bisect from itertools import accumulate def lowercase ( lowerCAmelCase__ : Dict , lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : Tuple ) -> Optional[int]: _...
45
from __future__ import annotations def UpperCamelCase ( _A ): # This function is recursive """simple docstring""" __magic_name__ : str = len(_A ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
342
0
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __snake_case = datasets.load_iris() __snake_case = np.array(data['''data''']) __snake_case = np.array(data['''target''']) __snake_case...
153
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration __snake_case = 500000 __snake_case ,__snake_case = os.path.split(__file__) __snake_case = os.path.join(RESULTS_BASEPATH, '''results''...
153
1
"""simple docstring""" from torch import nn class __lowerCAmelCase ( nn.Module ): '''simple docstring''' def __init__( self , _a , _a ): super().__init__() __a = class_size __a = embed_size # self.mlp1 = nn.Li...
45
'''simple docstring''' from __future__ import annotations import typing from collections import Counter def snake_case_ ( lowerCAmelCase_ )-> typing.Counter[int]: '''simple docstring''' _UpperCAmelCase : typing.Counter[int] = Counter() for base in ra...
215
0
"""simple docstring""" import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_con...
112
"""simple docstring""" import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch...
112
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class snake_case ( _lowerCAmelCase ): '''simple docstring''' @staticmethod @abstractmethod def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : ArgumentParser ): '''simple...
266
"""simple docstring""" import re def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" return [char.split() for char in re.split(r'''[^ a-z A-Z 0-9 \s]''' , str_ )] def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" __A ...
266
1
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): '''simple docstring''' lowercase_ = JukeboxTokenizer lowercase_ = { "artist": "Zac Brown Band", "g...
273
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTester...
273
1
def A_ ( _lowerCAmelCase , _lowerCAmelCase ) -> List[Any]: # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) UpperCamelCase : Any = (boundary[1] - boundary[0]) / steps UpperCamelCase : List[Any] = boundary[0] UpperCamelCase : List[st...
52
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceF...
52
1
"""simple docstring""" import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test,...
362
"""simple docstring""" def _A ( lowercase = 2_00_00_00 ): """simple docstring""" a =[0 for i in range(n + 1 )] a =1 a =1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
215
0
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class lower...
11
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCAmelCase__ = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
11
1
'''simple docstring''' import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from t...
368
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[Any] = logging.get_logger(__name__) def lowerCamelCase ( UpperCAmelCase__ : Union[tf.Tensor, np.ndarray] ) -> List[...
21
0
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins _A : Union[str, Any] =['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamel...
41
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__( unittest.TestCase ): ...
272
0
"""simple docstring""" from __future__ import annotations lowercase__ : Optional[Any] = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } class a__ : def __init__( sel...
352
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__ : Dict = [ ["attention", "attn"], ...
180
0
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Pa...
312
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def __snake_case ( __UpperCamelCase : NDArray[floataa] ,__UpperCamelCase : NDArray[floataa] ,__UpperCamelCase : list[int] ,__UpperCamelCase ...
312
1
'''simple docstring''' import math import os import sys def __lowerCamelCase ( __lowerCAmelCase : str ) -> str: snake_case = """""" try: with open(__snake_case , """rb""" ) as binary_file: snake_case = binary_fi...
355
'''simple docstring''' 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 __lowerCamelCase ( __lowerCA...
3
0
def UpperCamelCase ( __lowercase : int = 1_00_00_00 ): '''simple docstring''' A_ : Any = set(range(3 ,__lowercase ,2 ) ) primes.add(2 ) for p in range(3 ,__lowercase ,2 ): if p not in primes: continue primes.difference_update(set(...
140
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class __magic_name__ ( __lowerCAmelCase): def __init__( self :...
146
0
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 __lowerCamelCase ( lowerCamelCase__ : int ...
66
UpperCAmelCase : Tuple = "Tobias Carryer" from time import time class __lowercase : """simple docstring""" def __init__( self , A , A , A , A=int(time() ) ) -> Optional[int]: # noqa: B008 '''simple docstring''' ...
66
1
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironmen...
273
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch i...
20
0
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 : Union[str, Any] = logging...
308
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencep...
308
1
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class UpperCAm...
62
A__ = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} A__ = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _UpperCAmelCase ( snake_case , snake_case , snake_case ): """simple docstring""" _lowerCAmelCase = True _lowerCAmelCase ...
82
0
"""simple docstring""" import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class _UpperCAmelCase ( datasets.BuilderConfig): _lowerCAmelCase : ...
369
"""simple docstring""" def __lowercase ( _a = 4_000_000 ): snake_case_ : Dict = [] snake_case_, snake_case_ : List[str] = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_a ) snake_case_, snake_case_ : str = b,...
155
0
import math def UpperCAmelCase ( a_ ) -> str: """simple docstring""" __A = 0 __A = 0 while num > 0: __A = num % 8 __A = octal + (remainder * math.floor(math.pow(1_0 , a_ ) )) counter += 1 __A = math.floor(nu...
15
'''simple docstring''' import os import pytest from attr import dataclass _snake_case = 'us-east-1' # defaults region @dataclass class a__ : _SCREAMING_SNAKE_CASE : str _SCREAMING_SNAKE_CASE : str = 'arn:aws:iam::558105141721:role/sagemaker_execution_role' _SCREAMING...
250
0
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : float ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): raise ValueError('Length must be a positive.' ) return 3 * ((25 + 10 * (5 ...
95
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: '''simple docstring''' while a != 0: __snake_case , __snake_case : Union[str, Any] = b % a, a return b def __UpperC...
95
1
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class UpperCamelCase__ (pl.LightningModule ): '''simple docstring''' def __init__( self , UpperCamelCase__ ...
48
import logging 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,...
193
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowerCamelCase ( ...
153
"""simple docstring""" from collections.abc import Callable import numpy as np def A_ ( _lowerCAmelCase : Callable, _lowerCAmelCase : float, _lowerCAmelCase : float, _lowerCAmelCase : float, _lowerCAmelCase : float ): """simp...
153
1
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision...
81
"""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 imp...
202
0
"""simple docstring""" from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ = "x" , lowerCAmelCase__ = 10**-10 , lowerCAmelCase__ = 1 , ): ...
359
"""simple docstring""" from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .m...
241
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
348
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __snake_case = logging.get_logger(__name__) def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase )-> str: '''simple docstring''' ...
348
1
'''simple docstring''' from math import sqrt def UpperCamelCase ( _lowerCamelCase : int ): assert isinstance(_UpperCamelCase , _UpperCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" A__ = True # 0 and 1 are none primes. if nu...
368
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( UpperCamelCase__ ): __lowercase = (PNDMScheduler,) __lowercase = (("""num_inference_steps""", 50),) def ...
123
0