code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import 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, XLMRobertaXLForSequenceCl...
205
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForSeqaSeqLM ...
205
1
def __lowerCamelCase (UpperCAmelCase__ : list[list[int]] , UpperCAmelCase__ : int , UpperCAmelCase__ : int , UpperCAmelCase__ : set ): '''simple docstring''' SCREAMING_SNAKE_CASE = len(snake_case_ ), len(grid[0] ) ...
719
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
647
0
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class a__ ( lowerCamelCase_ , unittest.TestCase ): ...
216
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase ( metaclass=lowerCamelCase_ ): '''simple docstring''' SCREAMING_SNAKE_CASE_ : Dict = ["""torch""", """torchsde"""] def __init__( ...
247
0
import socket def __magic_name__( ) -> Union[str, Any]: '''simple docstring''' _lowerCamelCase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) _lowerCamelCase = socket.gethostname() _lowerCamelCase = 1_2312 sock.connect(...
710
from typing import List import numpy as np def __magic_name__( __UpperCAmelCase ) -> int: '''simple docstring''' _lowerCamelCase = {key: len(__UpperCAmelCase ) for key, value in gen_kwargs.items() if isinstance(__UpperCAmelCase , __UpperCAmelCase )} if le...
638
0
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__) lowerCAmelCase_ = { ...
39
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffuse...
574
0
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOC...
262
from __future__ import annotations def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = None , SCREAMING_SNAKE_CASE_ = None , SCREAMING_SNAKE_CASE_ = False , ) -> tuple[int, float, str]: lowerCamelCase : Union[str, Any] =...
262
1
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit from tran...
321
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase = 400_0000 ): lowercase__ : List[Any] = [0, 1] lowercase__ : Union[str, Any] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 lowercase__ : ...
152
0
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = OrderedDict( [ ...
387
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
387
1
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subprocess_async, ge...
354
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging lowercase_ = logging.get_logge...
354
1
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_util...
712
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_: Dict ={ 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Au...
415
0
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def __UpperCamelCase ( snake_case__ ): if not is_accelerate_available(): return method A_ : int = version.pars...
180
"""simple docstring""" import math import os import sys def __UpperCamelCase ( snake_case__ ): A_ : Optional[Any] = """""" try: with open(snake_case__ , """rb""" ) as binary_file: A_ : Union[str, Any] = binary_file.read() for dat in data: A_ ...
180
1
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin...
716
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMSch...
615
0
'''simple docstring''' import numpy as np def A (__lowerCamelCase :np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
5
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : List[Any] =logging.get_logger(__name__) _UpperCamelCase : Dict ={ 'asapp/sew-tiny-100k': 'https://huggingface.co/asapp/sew-tiny-100k/resol...
206
0
"""simple docstring""" lowerCAmelCase__ = [ (1_000, '''M'''), (900, '''CM'''), (500, '''D'''), (400, '''CD'''), (100, '''C'''), (90, '''XC'''), (50, '''L'''), (40, '''XL'''), (10, '''X'''), (9, '''IX'''), (5, '''V'''), (4, '''...
707
"""simple docstring""" from typing import Any class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self , snake_case__ ): """simple docstring""" lowerCAmelCase : Dict = data lowerCAmelCase : Any = None ...
681
0
'''simple docstring''' 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, XLMRobertaXLForMas...
262
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCAmelCase ( UpperCamelCase__ : BertModel , UpperCamelCase__ : str , UpperCamelCase__ : str ): ...
262
1
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def a_ ( lowerCamelCase ): UpperCAmelCase__ = test_file.split(os.path.sep ) if compo...
632
"""simple docstring""" from __future__ import annotations class snake_case : """simple docstring""" def __init__( self : Dict ,lowerCamelCase__ : list[list[int]] ): UpperCAmelCase__ = TypeError( 'Matrices must be formed from a list of z...
632
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowercase ( __A : Union[str, Any] ) -> Any: '''simple docstring''' if "cls_token" in name: snake_case : ...
36
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel ...
549
0
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class _a ( UpperCAmel...
618
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTo...
618
1
'''simple docstring''' import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.ut...
44
'''simple docstring''' import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher...
372
0
'''simple docstring''' import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common impor...
708
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline, UnCLIP...
448
0
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class __magic_name__ ( unittest.TestCas...
348
'''simple docstring''' import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester ...
109
0
from __future__ import annotations from collections.abc import Callable __lowerCAmelCase : Optional[Any] = list[list[float | int]] def __magic_name__ ( A : Optional[Any], A : int ): '''simple docstring''' a = len(lowerCamelCase__ ) a =...
721
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Acce...
662
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 logging A_: int = logging.get_logger(__name__) A_: Any = {"""vocab_file"""...
398
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow...
0
0
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_to...
704
'''simple docstring''' def lowerCAmelCase__ ( a_ : float , a_ : list[float] ) -> float: if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: raise ValueError('''Cash flows list cannot be emp...
599
0
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert...
129
"""simple docstring""" def _A ( __lowercase , __lowercase ): """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
129
1
"""simple docstring""" def _lowerCAmelCase ( __lowerCamelCase:int = 1_0_0 ): '''simple docstring''' __magic_name__ = n * (n + 1) * (2 * n + 1) / 6 __magic_name__ = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ =...
707
"""simple docstring""" import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffuser...
468
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", "microsoft/markuplm-large": "https://huggingf...
518
# 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 ...
518
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, ...
714
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class _UpperCamelCase ( lowerCAmelCase ): # to overwrite at feature extractactor specific tests ...
364
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ = { 'configuration_gpt_bigcode': ['GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTBigCodeConfig'], } try: if not is_torch_available(): ...
322
def UpperCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ) -> int: '''simple docstring''' def count_of_possible_combinations(UpperCAmelCase_ ) -> int: if target < 0: return 0 if target == 0: ...
322
1
import sys __lowercase : List[Any] = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """668966489504452...
702
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ...
66
0
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __SCREAMING_SNAKE_CASE : Optional[int] = 1.0_54_57_18_17E-34 # unit of ℏ : J * s __SCREAMING_SNAKE_CASE : Dict = 3E8 # unit of c : ...
670
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py snake_case : Optional[Any] ...
545
0
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __magic_name__ ( __UpperCAmelCase = "isbn/0140328726" ) -> Any: '''simple docstring''' __SCREAMING_SNAKE_CASE = olid....
721
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING a = logging.get_logger(__name__) a = { "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config.json", } class __a ( ...
13
0
def lowerCAmelCase_ ( __a , __a ) -> Optional[Any]: """simple docstring""" lowerCamelCase__: Union[str, Any] =len(__a ) lowerCamelCase__: Dict =len(__a ) lowerCamelCase__: Any =( first_str_length if first_str_length > second_s...
59
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: ...
121
0
def lowerCamelCase ( UpperCAmelCase__ : int , UpperCAmelCase__ : bool = False ) -> bool: if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check last digit ret...
707
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : List[Any] = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: ...
30
0
"""simple docstring""" def A ( snake_case__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = set({"""(""", """[""", """{"""} ) SCREAMING_SNAKE_CASE__ = set({""")""", """]""", """}"""} ) S...
196
"""simple docstring""" from __future__ import annotations def A ( snake_case__ ): '''simple docstring''' for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(...
196
1
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
447
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRobe...
447
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerConfig''', ]...
40
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transforme...
96
0
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_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_commo...
230
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast 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 lowercas...
230
1
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor _lowercase : List[Any] =logging.get_logger(__name__) class UpperCamelCase_ ( snake_case__ ): def __init__( self : Optional[Any] , ...
364
import argparse import json 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 a...
364
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
720
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( lowercase_ ): '''simple docstring''' SCREAMING_SNAKE_CASE = ["image_processor", "tokenizer"] SCREAMING_SNAKE_CASE = "AutoImageProcessor...
199
0
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proc...
478
def lowercase_ (A : int , A : int ): if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) snake_case__ : List[str] = str(bin(A ) )[2:] # remove the leading "0b" snake_case__ : int = ...
478
1
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel lowerCamelCase = False lowerCamelCase = True lowerCamelCase = False if __name__ == "__main__": lowerCamelCase ...
102
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProcessor from .modeling_...
102
1
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> Dict: if not is_accelerate_available(): return method snake_case__ = version.parse(...
33
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Union[str, Any] = { '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': ( ''...
452
0
'''simple docstring''' from collections.abc import Callable class __UpperCAmelCase : '''simple docstring''' def __init__( self , _SCREAMING_SNAKE_CASE = None ) -> None: # Stores actual heap items. A_ = [] # Stores indexes o...
721
'''simple docstring''' from collections import defaultdict from math import gcd def _UpperCAmelCase ( _UpperCamelCase : int = 1_50_00_00 ) -> int: A_ = defaultdict(_UpperCamelCase ) A_ = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: ...
174
0
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 ConfigTester from ...test_mode...
105
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smarta...
253
0
'''simple docstring''' 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...
713
from collections import deque from .hash_table import HashTable class _SCREAMING_SNAKE_CASE ( __snake_case ): '''simple docstring''' def __init__( self : Optional[int] , *__lowerCamelCase : List[Any] , **__lowerCamelCase : Optional[Any] ): ...
698
0
'''simple docstring''' import re from filelock import FileLock try: import nltk lowercase : int = True except (ImportError, ModuleNotFoundError): lowercase : List[str] = False if NLTK_AVAILABLE: with FileLock(""".lock...
116
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A (__UpperCAmelCase ): _SCREAMI...
326
0
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast 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 impo...
707
"""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/resolve/main/con...
348
0
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel lowerCAmelCase_ ...
414
# 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...
333
0
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """vocab_file""": """vocab.json""", """merges...
675
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """bert-base-uncased""": """https://huggingface...
675
1
"""simple docstring""" from collections import deque from .hash_table import HashTable class __a ( __a ): '''simple docstring''' def __init__( self , *_lowerCamelCase , **_lowerCamelCase ) -> Any: '''sim...
118
"""simple docstring""" import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.p...
118
1
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attent...
370
"""simple docstring""" SCREAMING_SNAKE_CASE_ = 0 # The first color of the flag. SCREAMING_SNAKE_CASE_ = 1 # The second color of the flag. SCREAMING_SNAKE_CASE_ = 2 # The third color of the flag. SCREAMING_SNAKE_CASE_ = (red, white, blue) def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE...
370
1
'''simple docstring''' def __UpperCAmelCase ( A : float ) -> float: return 1_0 - x * x def __UpperCAmelCase ( A : float , A : float ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(__UpperCamelCase ) * eq...
541
from typing import TYPE_CHECKING from ...utils import _LazyModule _lowerCamelCase = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys _lowerCamelCase ...
144
0
"""simple docstring""" from math import isqrt def __a ( A ): '''simple docstring''' return all(number % divisor != 0 for divisor in range(2 , isqrt(A ) + 1 ) ) def __a ( A = 10**6 ): '''simp...
704
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class a__ ( _a ): snake_case_ = (IPNDMScheduler,) snake_case_ = (("num_inference_steps", 50),) def snake_case__ ( self, **...
668
0
def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" if not isinstance(a_ , a_ ): __A = F'''Input value of [number={number}] must be an integer''' raise TypeError(a_ ) if number < 0: return False __A = number * num...
55
"""simple docstring""" class lowerCAmelCase__ : def __init__( self , UpperCamelCase__ , UpperCamelCase__=None , UpperCamelCase__=None ): '''simple docstring''' A__ = data A__ = previous A__ = next_node def __str__( s...
337
0
"""simple docstring""" import cmath import math def lowerCAmelCase (__UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : float , __UpperCamelCase : float ): """simple docstring""" __UpperCamelCa...
296
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __lowercase = 299_792_458 # Symbols __lowercase , __lowercase , __lowercase , __lowercase = symbols('''ct x y z''') def low...
296
1
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = '▁' __a = {'vocab_file':...
97
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational...
396
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : Optional[Any] = {"configuration_vit": ["VIT_PRETRAINED...
721
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_...
441
0
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): imp...
202
"""simple docstring""" 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 transfor...
223
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/...
377
'''simple docstring''' 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, neste...
377
1
from ...configuration_utils import PretrainedConfig lowerCamelCase : List[Any] = { "google/tapas-base-finetuned-sqa": ( "https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json" ), "google/tapas-base-finetuned-wtq": ( "https:...
70
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_...
180
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 ( unittes...
714
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : Tuple = logging.get_logger(__name__) UpperCamelCase_ : Optional[int] = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve...
482
0
def __snake_case ( lowerCAmelCase_ = 1_0_0 ) -> int: SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ ...
100
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_ima...
85
0
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor lowercase = logging.getLogger(__name__) lowercase = 50 # max ...
714
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase = { """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
150
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_doc...
645
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils...
428
0
'''simple docstring''' from itertools import count def A_ ( _lowerCAmelCase : Optional[int] = 50 ): """simple docstring""" _lowerCamelCase : int = [1] * min_block_length for n in count(__lowerCAmelCase ): fill_count_functions...
717
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_av...
11
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : int = 10**12 ): """simple docstring""" __a = 1 __a = 0 __a = 1 __a = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * numerator numerator += 2 * prev_numerator prev...
225
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase ( __snake_case : List[str] , __snake_case : Any=False ): lowercase_ : List[str...
231
0
"""simple docstring""" import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _UpperCamelCase : List[str] = '\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n ...
134
"""simple docstring""" from PIL import Image def _SCREAMING_SNAKE_CASE ( __snake_case : Image ): '''simple docstring''' lowercase , lowercase = image.size lowercase = 0 lowercase = image.load() for i in range(__snake_case ): ...
134
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _snake_case : int = { 'configuration_clip': [ ...
53
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def a_ ( lowerCAmelCase_ : Optional[Any], lowerCAmelCase_ : List[Any], lowerCAmelCase_ : str ...
53
1
'''simple docstring''' import numpy as np def lowerCamelCase_ ( A_ , A_ ): return np.where(vector > 0 , A_ , (alpha * (np.exp(A_ ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
575
'''simple docstring''' from statistics import mean import numpy as np def lowerCamelCase_ ( A_ , A_ , A_ , A_ ): __lowerCamelCase = 0 # Number of processes finished __lowerCamelCase = 0 # Displays the finished process. # If it is 0, the pe...
575
1
"""simple docstring""" import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from ...
227
"""simple docstring""" import argparse import datetime def UpperCAmelCase ( snake_case : str ): _lowerCAmelCase:Dict = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', '''3''': '''Wednesday''', '''4''': ''...
227
1
from __future__ import annotations def lowerCamelCase_ ( UpperCAmelCase_ : list ) -> float: '''simple docstring''' if not nums: raise ValueError('List is empty' ) return sum(UpperCAmelCase_ ) / len(UpperCAmelCase_ ) if __name__ == "__main__": import doctest...
648
import functools def lowerCamelCase_ ( UpperCAmelCase_ : list[int] , UpperCAmelCase_ : list[int] ) -> int: '''simple docstring''' if not isinstance(UpperCAmelCase_ , UpperCAmelCase_ ) or not all(isinstance(UpperCAmelCase_ , ...
648
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): im...
298
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py lowercase : List[str] = """.""" if __name__ == "__main__": lowercase : List...
116
0
# 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 ap...
444
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_atte...
444
1
import numpy as np from PIL import Image def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ): lowerCamelCase_ : str = np.array(lowerCAmelCase__ ) if arr.shape[0] != arr.shape[1]: raise ValueError('The input array is n...
364
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowercase : int =logging.get_logger(__name__) class UpperCamelCase_ ( snake_case__ ): def __init__( self : Tuple , *lowerCamelC...
364
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.jso...
720
import random class SCREAMING_SNAKE_CASE__ : @staticmethod def SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE__ : str ) -> tuple[list[int], list[int]]: a_ : int = [ord(SCREAMING_SNAKE_CASE__ ) for i in text] a_ : Any = ...
443
0
"""simple docstring""" import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def lowercase__ ( snake_case_ :List[str] , snake_case_ :...
49
"""simple docstring""" from cva import destroyAllWindows, imread, imshow, waitKey def _lowerCAmelCase ( _UpperCamelCase ): """simple docstring""" _lowercase , _lowercase: Union[str, Any] = img.shape[0], img.shape[1] # converting each pixel's color to its negative for ...
353
0
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a_ = '''.''' # Internal TensorFlow ops that can be safely ign...
115
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _a ( Upper...
115
1
"""simple docstring""" from collections.abc import Sequence def lowercase ( __snake_case : Tuple , __snake_case : Dict ): return sum(c * (x**i) for i, c in enumerate(SCREAMING_SNAKE_CASE__ ) ) def lowercase ( __s...
231
'''simple docstring''' import datasets from .evaluate import evaluate lowercase__ = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={a...
638
0
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __A : int = 0 __A : Tuple = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0...
267
'''simple docstring''' import torch from transformers import AutoModel class __UpperCamelCase ( torch.nn.Module ): def __init__( self :Union[str, Any] ,_UpperCamelCase :Tuple="sayef/fsner-bert-base-uncased" ): super(_UpperCamelCase ,self ).__init__() sn...
267
1
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio...
259
def SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case ) -> bool: return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(snake_case ) ) def SCREAMING_SNAKE_CASE ( snake_case , snake_case ...
375
0
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : Any ) -> int: '''simple docstring''' if not isinstance(_lowercase , _lowercase ): raise ValueError('Input must be an integer' ) if input_num <= 0: raise ValueError...
704
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''roberta-base''': '''https:/...
320
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbosi...
37
'''simple docstring''' from timeit import timeit __UpperCamelCase : int = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": Tr...
448
0
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) _lowercase : Tuple =2_9_9_7_9_2_4_5_8 # Symbols _lowercase : Any =symbols('''ct x y z''') def A__ ( lowercase: float ) -> float: ...
711
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments _lowercase : Any =logging.getLogger(__name__) @dataclass class SCREAMING_SNAKE_CASE_ ( lowerCAmelCa...
661
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/ma...
585
'''simple docstring''' import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __lowerCAmelCase = logging.getLogger(__name__) def __SCREAMING_SNAKE_CASE ( ): _snake_case = argparse.ArgumentParser( description=""...
585
1
import copy import re class A__ : UpperCAmelCase = "hp" UpperCAmelCase = {} UpperCAmelCase = None @classmethod def __UpperCamelCase ( cls : Optional[int] , _a : Optional[int] ...
703
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_to...
191
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Dict = logging.get_logger(__name__) lowerCamelCase_ : int = { """google/pix2struct-textcaps-base""": ( """https:...
559
import math import sys def lowerCAmelCase( __lowerCamelCase ): if number != int(__lowerCamelCase ): 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' ) if number == 0:...
559
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin...
717
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock fr...
598
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered...
47
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: __lowerCAmelCase : Optional[int] = None try: import msvcrt except ImportError: __lowerCAmelCase : List[Any] = None try: import fcntl except Impor...
644
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> str: __lowerCamelCase : Optional[int] = '' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) ...
703
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a ={ """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], """tokenization_xlm""": ["""XLMTokenizer"""], } ...
337
0
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCamelCase__ ( _a): return getitem, k def lowerCamelCase__ ( _a , _a): return setitem, k, v def lowerCamelCase__ ( _a): return delitem, k def l...
25
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: ...
25
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torc...
713
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") A : str = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) A : Optional[int] = requests.get(url...
5
0
from __future__ import annotations def a__ ( _UpperCamelCase : list[int] ): if not nums: return 0 __lowerCamelCase = nums[0] __lowerCamelCase = 0 for num in nums[1:]: __lowerCamelCase ,__lowerCamelCase = ( max_excluding + n...
175
import numpy # List of input, output pairs a_ = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) a_ = (((515, 22, 13), 555), ((61, 35, 49), 150)) a_ = [2, 4, 1, 5] a_ = len(train_data) a_ = ...
175
1
"""simple docstring""" def UpperCamelCase ( _A , _A ) -> float: if digit_amount > 0: return round(number - int(_A ) , _A ) return number - int(_A ) if __name__ == "__main__": print(decimal_isolate(1.53, 0)) print(decimal_isolate(35.345...
348
"""simple docstring""" def UpperCamelCase ( _A , _A ) -> str: lowercase : list[list[str]] = [[] for _ in range(_A )] lowercase : Any = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) i...
348
1
def _UpperCAmelCase ( UpperCAmelCase : int | float | str ): """simple docstring""" try: __lowerCamelCase : Dict = float(UpperCAmelCase ) except ValueError: raise ValueError("""Please enter a valid number""" ) __lowe...
519
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) ...
519
1
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): _lowercase: Dict = { "en": "Machine learning is great, isn't it?", "ru": "Машинное обучение - это здорово, не так...
206
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version _SCREAMING_SNAKE_C...
206
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterM...
541
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from...
541
1
'''simple docstring''' import numpy as np UpperCAmelCase_ : List[Any] = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v"""...
705
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) ...
440
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ : List[Any] ...
673
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
673
1
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from...
712
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __magic_name__ : Optional[Any] = logging.get_logger(__name__) __magic_name__ : Tuple = { 'google/umt5-small': 'h...
608
0