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 logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
87
'''simple docstring''' from dataclasses import dataclass from typing import 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 .modeling_utils import ModelMixin from .vae impor...
125
0
import torch def _lowerCamelCase ( ): """simple docstring""" if torch.cuda.is_available(): _lowerCamelCase = torch.cuda.device_count() else: _lowerCamelCase = 0 print(F'''Successfully ran on {num_gpus} GPUs''' ) if __name__ == "__main__": main()
713
from __future__ import annotations from typing import Any def _lowerCamelCase ( _a ): """simple docstring""" if not postfix_notation: return 0 _lowerCamelCase = {'''+''', '''-''', '''*''', '''/'''} _lowerCamelCase = [] for token in postfix_notation: if toke...
297
0
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() __SCREAMING_SNAKE...
234
import numpy as np __SCREAMING_SNAKE_CASE =[ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z""...
234
1
"""simple docstring""" def lowercase__ ( lowercase_ ) -> int: """simple docstring""" if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 ,len(grid[0] ) ): grid[0][cel...
51
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowerCamelCase__ = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that g...
51
1
import argparse import os import re import packaging.version __a = """examples/""" __a = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(R"""^__version__\s+=\s+\"([^\"]+)\"\s...
377
def _UpperCamelCase ( lowerCAmelCase_ ) ->int: if n == 1 or not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): return 0 elif n == 2: return 1 else: UpperCAmelCase = [0, 1] for i in range(2 , n + 1 ): sequence.append(sequence[i - 1] + s...
377
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, Hf...
169
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 snake_case_ : Tuple = False class __snake_case ( unittest.Test...
169
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from tr...
320
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A = logging.get_logger(__name__) A ...
320
1
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(_UpperCamelCase , n - 1 , _UpperCamelCase ) * a) % mod else: __lowerCAmelCase : Dict = binar...
549
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase = False ): if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : str = F"Expected string as input, found {type(_UpperCamelCase )}" raise ValueError(_UpperCamelCase ) if not i...
549
1
"""simple docstring""" from datetime import datetime import requests def __A (_SCREAMING_SNAKE_CASE ) ->Union[str, Any]: """simple docstring""" lowerCAmelCase__ :str = '''https://downloadgram.net/wp-json/wppress/video-downloader/video?url=''' lowerCAmelCase__ :L...
93
'''simple docstring''' from math import factorial def _a ( __lowerCAmelCase : int = 20 ): """simple docstring""" snake_case__ : Union[str, Any] = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... snake_case__ : Lis...
347
0
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.co/b...
207
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""", """VisionEncoderDecoderO...
207
1
from __future__ import annotations def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_ ,UpperCamelCase_ ,): """simple docstring""" snake_case = len(UpperCamelCase_ ) # If row is equal to the size...
550
from ..utils import DummyObject, requires_backends class A__ ( metaclass=snake_case__ ): """simple docstring""" __magic_name__ = ['flax', 'transformers'] def __init__( self , *__snake_case , **__snake_case ): requires_ba...
550
1
import warnings 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 _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { "nvi...
297
import heapq def _lowerCamelCase ( _a ): """simple docstring""" _lowerCamelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, s...
297
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=__a ): __SCREAMING_SNAKE_CASE :str = ["note_seq"] def __init__( self : int , *a__ : Optional[int] , **a__ : Dict ...
432
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.scheduling_ddpm ...
147
0
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
315
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __lowercase : Union[str, Any] = logging.get_logger(__name__) __lowercase : Optional[Any] = r''' Args: i...
315
1
"""simple docstring""" class _snake_case : '''simple docstring''' def __init__( self : Optional[int] , snake_case : list[int] ): UpperCAmelCase_ :List[Any] = len(snake_case ) UpperCAmelCase_ :Dict = [0] * len_array if l...
608
"""simple docstring""" from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def ...
608
1
"""simple docstring""" from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def UpperCAmelCase__ ( lowerCAmelCase__ :Union[str, Any] , lowerCAmelCase__ :Tuple ) -> Dict: '''simp...
718
"""simple docstring""" 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, On...
197
0
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase : ...
696
import os import sys import unittest __lowerCAmelCase : List[Any] =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_obj...
696
1
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ......
705
"""simple docstring""" import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from tran...
342
0
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class a_ ( a , unittest.TestCase ): A__ ...
598
def a_ ( __magic_name__ = 1_000 ) -> int: """simple docstring""" snake_case , snake_case : Optional[Any] = 1, 1 snake_case : Optional[Any] = 2 while True: snake_case : Dict = 0 ...
598
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/microsoft/unispeech-large-1500h...
452
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_processi...
452
1
'''simple docstring''' import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import hugg...
44
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCamelCase = (3, 9, -11, 0, 7, 5, 1, -1) UpperCamelCase = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _lowerCamelCase : """simple docs...
590
0
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_...
721
'''simple docstring''' import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenizati...
568
0
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCamelCase : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name cla...
70
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(): import ...
70
1
"""simple docstring""" def a__ ( __lowercase ) -> list: if any(not isinstance(__lowercase , __lowercase ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(__lowercase ) ): for i, (rod_uppe...
621
"""simple docstring""" import numpy as np def a__ ( __lowercase , __lowercase ) -> np.ndarray: return np.where(vector > 0 , __lowercase , (alpha * (np.exp(__lowercase ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
621
1
"""simple docstring""" import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTester...
134
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase__ :Union[str, Any] = argparse.ArgumentParser('Stable Diffusion script with intel optimizat...
522
0
'''simple docstring''' def lowercase_ ( _lowercase ) -> Optional[Any]: '''simple docstring''' lowerCamelCase_ : Optional[int] = 0 while len(_UpperCAmelCase ) > 1: lowerCamelCase_ : Tuple = 0 # Consider two files with minimum cost to be...
716
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : str = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': [''...
357
0
import warnings from .generation import TFGenerationMixin class lowercase_ ( _UpperCAmelCase ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in T...
443
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartToke...
339
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config....
717
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__ ( lowerCAmelCase__ ): lowerCAme...
688
0
# 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 app...
55
'''simple docstring''' import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { '''facebook/data2vec-base-960h''': '''https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/m...
508
0
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .p...
176
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_com...
176
1
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPTDoubleHea...
60
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : List[Any]=2_81_23 ) -> str: __snake_case = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): ...
69
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( _UpperCamelCase ): """simple docstring""" @staticmethod @abstractmethod def lowercase ( lowerCAmelCase_ : ArgumentParser ) -> int: raise NotImplementedError...
421
_snake_case : List[Any] = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] _snake_case : Lis...
421
1
__UpperCamelCase : Tuple = 8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("""Invalid inputs. Enter positive value.""" ...
80
def lowerCAmelCase_ ( __UpperCAmelCase: str ) -> bool: return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''') ) def lowerCAmelCase_ ( __UpperCAmelCase: str ) -> bool: UpperCamelCase__ : Tuple ...
253
0
'''simple docstring''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights f...
702
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __A : Optional[int] = datasets.load_iris() __A : Optional[Any] = np.array(data['data']) __A : Tuple = np.a...
126
0
'''simple docstring''' import unittest from transformers import DonutProcessor a = "naver-clova-ix/donut-base" class __a ( unittest.TestCase ): def UpperCAmelCase__ ( self : int ): '''simple docstring''' __SCREAMING_SNAKE_CASE = Donut...
109
"""simple docstring""" A_ = 2_56 # Modulus to hash a string A_ = 1_00_00_03 def UpperCAmelCase__ (snake_case__ : str , snake_case__ : str ): """simple docstring""" _snake_case : Any = len(snake_case__ ) _snak...
609
0
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC __lowerCamelCase : Any = parse(importlib.metadata.version("""torch""")) def A__ ( _a : Union[str, Version] , _a : str , _...
448
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_...
448
1
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get_file...
113
import inspect 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_config_docstrings.py _lowerCAmelCase : int ="""src/transformers""" # This is to make sure the ...
113
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowerCamelCase : str = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLConfig'''], '''tokenization_transfo_x...
516
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar _lowerCamelCase : Optional[int] = TypeVar('''T''') class lowerCAmelCase__ ( Generic[T] ): '''simple docstring''' def __init__( self , ...
516
1
"""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_tenso...
65
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } tr...
3
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_at...
708
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json""", """microsoft/markuplm-large""": """htt...
488
0
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort lowerCAmelCase__ = '''1''' lowerCAmelCase__ = '''0''' lowerCAmelCase__ = '''1''' lowerCAmelCase__ = ort.SessionOptions() lowerCAmelCase__ ...
83
"""simple docstring""" from collections import namedtuple lowerCAmelCase__ = namedtuple('''from_to''', '''from_ to''') lowerCAmelCase__ = { '''cubicmeter''': from_to(1, 1), '''litre''': from_to(0.0_0_1, 1000), '''kilolitre''': from_to(1, 1), '''gallon'''...
83
1
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Union[str, Any] = 0 __lowerCamelCase : Optional[Any] = number while duplicate > 0: ...
230
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class A_ ( __UpperCamelCase , unittest.TestCase...
230
1
'''simple docstring''' import json import sys def UpperCAmelCase__( _SCREAMING_SNAKE_CASE : List[str],_SCREAMING_SNAKE_CASE : Any ): """simple docstring""" with open(_SCREAMING_SNAKE_CASE,encoding='utf-8' ) as f: __A= json.load(_SCREAMING_SNAKE_CASE ) __A= ['<det...
186
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil UpperCAmelCase__ = 1_0_0 UpperCAmelCase__ = set(range(3, NUM_PRIMES, 2)) primes.add(2) UpperCAmelCase__ = 42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not...
186
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImagePro...
524
"""simple docstring""" from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig _snake_case : Optional[int] = logging.get_logger(__name__) _snake_case : Optional[int] = 'T5Config' class ...
524
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase : List[Any] = { "configuration_nezha": ["NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP", "NezhaConfig"], } try: if not is_torch_available(): ...
542
import string from math import logaa def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): A : List[str] = document.translate( str.maketrans('''''' , '''''' , string.punctuation ) ).replace('''\n''' , '''''' ) ...
542
1
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision...
487
"""simple docstring""" import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class a__ : lowercase_ = None def a_ ( self : List[Any]): """simple docstring""" __UpperCAmelCase : Optional[An...
487
1
'''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 lowercase__ : Any = False class __lowerCAmelCase ( unitte...
98
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_av...
542
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, req...
103
from abc import ABC, abstractmethod from argparse import ArgumentParser class __A( UpperCAmelCase ): @staticmethod @abstractmethod def lowercase__ ( __UpperCamelCase : ArgumentParser ): raise NotImplementedError() @abstractmetho...
103
1
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softm...
101
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging logging...
297
0
from collections.abc import Callable import numpy as np def __UpperCamelCase ( A , A , A , A , A ): UpperCamelCase__ = int(np.ceil((x_end - xa) / step_size ) ) UpperCamelCase__ = np.zeros((n + 1,) ) ...
469
import math import tensorflow as tf from packaging import version def __UpperCamelCase ( A ): UpperCamelCase__ = tf.convert_to_tensor(A ) UpperCamelCase__ = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype ) ...
469
1
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_timm,...
611
'''simple docstring''' from __future__ import annotations def __UpperCamelCase( _A : list[int] , _A : int , _A : int , _A : int ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[in...
614
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowerCamelCase : int = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_avail...
714
import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_property from ...test_t...
501
0
import json from typing import 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_roberta import Ro...
79
'''simple docstring''' from __future__ import annotations __UpperCamelCase = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCas...
26
0
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _SCREAMING_SNAKE_CASE( snake_case_ : int , snake_case_ : int , snake_case_ : float = 1 / sqrt(2 ) ) ->IIRFilter: ...
411
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, ...
411
1
"""simple docstring""" from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_av...
341
"""simple docstring""" import unittest from transformers import 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...
341
1
def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> bool: """simple docstring""" __A = 0 for ch in input_str: __A = ord(__lowercase ) __A = pow(2 , __lowercase ) # If we already turned on bit for current charact...
199
from typing import TYPE_CHECKING from ...utils import _LazyModule __a : Optional[int] = {"tokenization_bertweet": ["BertweetTokenizer"]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys __a : int = _LazyModule(__name__, globa...
199
1
from __future__ import annotations class lowercase : def __init__( self , snake_case=None ): snake_case_ = data snake_case_ = None def __repr__( self ): snake_case_ = [] snake_case...
362
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAm...
362
1
"""simple docstring""" from graphs.minimum_spanning_tree_kruskal import kruskal def lowercase__ ( ) -> Optional[Any]: '''simple docstring''' a__ : Any = 9 a__ : List[Any] = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, ...
251
"""simple docstring""" def lowercase__ ( lowerCAmelCase__ : int ) -> bool: '''simple docstring''' if num < 0: return False a__ : int = num a__ : int = 0 while num > 0: a__ : Dict = rev_num * 1_0 + (num % 1_0) num //= 1_0 ...
251
1
import re from ..models.auto import AutoProcessor from ..models.vision_encoder_decoder import VisionEncoderDecoderModel from ..utils import is_vision_available from .base import PipelineTool if is_vision_available(): from PIL import Image class __lowerCamelCase (__UpperCamelCase ): ...
1
"""simple docstring""" def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" return abs(lowerCamelCase__ ) if a == 0 else greatest_common_divisor(b % a , lowerCamelCase__ ) def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCa...
644
0
import heapq def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : dict ) -> set[int]: """simple docstring""" SCREAMING_SNAKE_CASE__ = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq modul...
379
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : List[Any] = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''In...
379
1
import numpy as np import datasets SCREAMING_SNAKE_CASE__ = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was introduced by Prof. ...
9
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, ...
315
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ : Any = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
714
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder lowerCAmelCase__ : List[Any] = datasets.utils.logging.get_logger(__name__) class __snake_case ( folder_based_builder.FolderBasedBuild...
699
0
'''simple docstring''' def lowercase__( _UpperCamelCase : Tuple = 1000 )-> Dict: """simple docstring""" return sum(e for e in range(3 , _UpperCamelCase ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"""{solution() = }""")
138
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig 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 i...
681
0
from __future__ import annotations def A ( _lowercase , _lowercase = None , _lowercase = None , _lowercase = False , ) -> Tuple: SCREAMING_SNAKE_CASE : List[str] = cipher_alphabet or [chr(UpperCAmelCase__ ) for i in range(97 , 123 )] #...
713
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker...
34
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
383
from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase_ : """simple docstring""" def __init__( self ) -> List[str]: __UpperCamelCase = {} def __lowercase( self , _SCREAMING_SNAKE_CASE ) ->...
383
1
'''simple docstring''' def _A ( snake_case__ : Any = 1_00 ): snake_case__ : Any = (n * (n + 1) // 2) ** 2 snake_case__ : Dict = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F'''{solution() = }''')
711
'''simple docstring''' def _A ( snake_case__ : float ): return 10 - x * x def _A ( snake_case__ : float , snake_case__ : float ): # Bolzano theory in order to find if there is a root between a and b if equation(snake_case__ ) * equation(snake_case__ ) >= 0: ...
694
0
"""simple docstring""" import warnings from .generation import TFGenerationMixin class UpperCamelCase ( _SCREAMING_SNAKE_CASE ): warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ''' '''b...
389
"""simple docstring""" from math import ceil def __a ( a, a ): """simple docstring""" _a = list(range(0, a ) ) _a = [item for sublist in list(device_map.values() ) for item in sublist] # Duplicate check _a ...
388
0
def __lowercase ( lowerCamelCase_ : list , lowerCamelCase_ : list , lowerCamelCase_ : int , lowerCamelCase_ : int , lowerCamelCase_ : int ): if index == number_of_items: return 0 SCREAMING_SNAKE_CASE__ = 0 S...
707
"""simple docstring""" from math import factorial def __lowercase ( lowerCamelCase_ : int = 100 ): return sum(int(lowerCamelCase_ ) for x in str(factorial(lowerCamelCase_ ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
112
0
'''simple docstring''' from math import loga def UpperCamelCase__ ( __magic_name__ : int ) -> int: '''simple docstring''' if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(__magic_name__ , __magic_name__ ): ra...
38
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessi...
149
0
'''simple docstring''' import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSF...
715
'''simple docstring''' 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,...
44
0
import argparse import datetime def UpperCamelCase_( _snake_case : str ): """simple docstring""" __a ={ '0': 'Sunday', '1': 'Monday', '2': 'Tuesday', '3': 'Wednesday', '4': 'Thursday', '5': 'Friday', ...
242
from jiwer import compute_measures import datasets _lowerCAmelCase : Union[str, Any] = "\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and W...
242
1
'''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, ) _UpperCamelCase : Any ={"conf...
703
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase : List[str] ={ "configuration_bigbird_pegasus": [ "BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP", "BigBirdPegasusC...
575
0
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup lowerCAmelCase__: Dict = logging.get_logger(__name__) class s...
345
import sys import turtle def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_ ) -> tuple[float, float]: return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_, snake_case_, snake_case_, ) -...
416
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A : List[str] = { 'configuration_gpt_neo': ['GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoConfig', 'GPTNeoOnnxConfig'], } try: if not is_torch_available(): ...
75
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available ...
75
1
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _snake_case (__lowercase , __lowercase , __lowercase): #...
23
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.dumm...
348
0
'''simple docstring''' import re import subprocess import sys snake_case : str = subprocess.check_output('git merge-base main HEAD'.split()).decode('utf-8') snake_case : Optional[int] = ( subprocess.check_output(F"""git diff --diff-filter=d --name-only {fork_point_sha}""".split...
711
'''simple docstring''' import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBa...
339
0
import re from filelock import FileLock try: import nltk a__ : Optional[int] = True except (ImportError, ModuleNotFoundError): a__ : str = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def ...
188
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 from .tokenization_gpta import GPTaTokenizer ...
217
0
"""simple docstring""" def __a ( _lowercase , _lowercase , _lowercase ): """simple docstring""" return round(float(moles / volume ) * nfactor ) def __a ( _lowercase , _lowercase , _lowercase ): """simple docstring""" ...
720
"""simple docstring""" import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def __a ( _lowercase , _lowercase , _lowerc...
121
0
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _UpperCAmelCase ( *A , A = None , A=True , A=2 ): '''simple docstring''' from .. import __version__ UpperCAmelCase_...
625
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class snake_case_ ( a ): '''simple docstring''' __UpperCamelCase = 'EncodecFeatureExtractor' __UpperCamelCase ...
625
1
"""simple docstring""" import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed....
715
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __A : Optional[Any] = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP...
595
0
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class UpperCAmelCase : '''simple docstring''' SCREAMING_SNAKE_CASE_...
42
'''simple docstring''' 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 ...
42
1
import json import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_i...
715
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor UpperCAmelCase = logging.get_logger(__name__) class A_ ( __lowerCamelCase ): '''simple docstring''' def __init__( self , *snake_case , **snake_case ): warnings.warn( ...
565
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ : Optional[int] = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: if ...
31
def UpperCAmelCase_ ( ) -> list[list[int]]: return [list(range(10_00 - i , -10_00 - i , -1 ) ) for i in range(10_00 )] lowerCamelCase__ : List[Any] = generate_large_matrix() lowerCamelCase__ : List[Any] = ( [[4, 3, 2, -1], [3,...
31
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=lowercase__ ): """simple docstring""" a : Any =["torch", "scipy"] def __init__( self , *snake_case__ , **snake_case__ ): ...
700
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available fro...
681
0
"""simple docstring""" def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__ = 1_000 ) -> int: a_ : List[Any] = 2**power a_ : Dict = 0 while n: a_ , a_ : Union[str, Any] = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(i...
237
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING...
237
1
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): # noqa: E741 __UpperCAmelCase : Any = len(_UpperCAmelCase ) __UpperCAmelCase : Dict = 0 __UpperCAmelCase : List[Any] = [0] * n __UpperCAmelCase : Any = ...
711
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase__ : int = {"configuration_encoder_decoder": ["EncoderDecoderConfig"]} try: if ...
329
0
'''simple docstring''' import inspect import unittest from transformers import DecisionTransformerConfig, 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 f...
13
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase_ : Any = logging.get_logger(__name__) # TODO: upload to AWS UpperCamelCase_ : List[str] = { '''yjernite/retribert-base-uncased''': ( '...
115
0
'''simple docstring''' from math import sqrt def _SCREAMING_SNAKE_CASE ( snake_case_ = 1000000 ): '''simple docstring''' _lowercase = 0 _lowercase = 0 _lowercase = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , ...
714
'''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_distilbert import DistilBertTokenizer _lowerCamelCase = logging.get_logger(_...
572
0
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def A_ ( _UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: str = arg...
671
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampli...
671
1
'''simple docstring''' from __future__ import annotations def A_ ( snake_case ): SCREAMING_SNAKE_CASE:List[Any] = str(_lowercase ) return n == n[::-1] def A_ ( snake_case = 1000000 ): SCREAMING_SNAKE_CASE:int = 0 for i in range(1 , _lowercase ): ...
712
'''simple docstring''' from ..utils import DummyObject, requires_backends class _snake_case ( metaclass=_a ): _A : Any = ['''torch''', '''torchsde'''] def __init__( self : Any ,*SCREAMING_SNAKE_CASE__ : int ,**SCREAMING_SNAKE_CASE__ ...
465
0
"""simple docstring""" # XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _UpperCamelCase = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa ...
453
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.util...
453
1
"""simple docstring""" import numpy as np class UpperCAmelCase__ : def __init__( self : Optional[int] ) -> Optional[int]: '''simple docstring''' A = (0, 0) A = None A = 0 A = 0 ...
109
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTest...
109
1
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase: Optional[Any] ="https://www.indeed.co.in/jobs?q=mobile+app+development&l=" def __snake_case ( __A = "mumbai"...
607
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase: str ={ "configuration_convbert": ["CONVBERT_PRETRAINE...
607
1
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokeniz...
701
def __lowerCamelCase ( _lowerCAmelCase ) -> Dict: _UpperCAmelCase = [0] * len(_lowerCAmelCase ) _UpperCAmelCase = [] _UpperCAmelCase = [] _UpperCAmelCase = 0 for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(_lowerCAmelCas...
129
0
class __A : def __init__( self : Dict , UpperCAmelCase_ : Any , UpperCAmelCase_ : int ): lowerCAmelCase : Optional[Any] = name lowerCAmelCase : int = val def __str__( self :...
343
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Tuple: '''simple docstring''' lowerCAmelCase : Any = [] lowerCAmelCase : Dict = [] lowerCAmelCase : int = { '^': 3, '*': 2, '/': 2, ...
343
1
'''simple docstring''' import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow...
350
'''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...
350
1
"""simple docstring""" from functools import lru_cache def lowerCamelCase_(__SCREAMING_SNAKE_CASE )-> set: _SCREAMING_SNAKE_CASE : Union[str, Any] = 2 _SCREAMING_SNAKE_CASE : Dict = set() while i * i <= n: if n % i: i += 1...
338
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowerCAmelCase_ = argparse.ArgumentParser( description=( '''Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for T...
338
1
"""simple docstring""" 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 __lowercase ...
713
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
48
0
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup __magic_name__ = "https://www.indeed.co.in/jobs?q=mobile+app+development&l=" def _lowerCAmelCase ( UpperCamelCase_ = "mumbai" ): __SCREAMI...
155
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "facebook/s2t-small-librispeech-asr": ( "https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config...
155
1
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _lowerCAmelCase : """simple docstring""" lowerCAmelCase = 42 lowerCAmelCase ...
713
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets lowercase : Union[str, Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground tru...
159
0