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
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _UpperCamelCase (_lowerCamelCase : Union[dict, list, ...
24
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IMAGE_GENERA...
167
0
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def a__ ( snake_case__ ) -> None: lowerCamelCase , lowerCamelCase = analyze_text(snake_case__ ) lowerCamelCase ...
720
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __magic_name__ ...
533
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
430
'''simple docstring''' def __lowerCamelCase ( A__ , A__ ) -> bool: """simple docstring""" UpperCamelCase = len(A__ ) UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for e...
430
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers imp...
715
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _UpperCamelCase ( _a : NDArray[floataa] , _a : NDArray[floataa] , _a : list[int] , _a : int , ): """simple docstring""" __Up...
287
0
from __future__ import annotations def _lowercase ( a__ : str ) -> list[int]: """simple docstring""" return [ord(a__ ) - 96 for elem in plain] def _lowercase ( a__ : list[int] ) -> str: """simple docstring""" return "".join(chr(elem + 96 ...
147
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar __lowerCAmelCase = TypeVar("""T""") __lowerCAmelCase = TypeVar("""U""") class lowerCamelCase_ ( Generic[T, U] ): def __init__( self , lowerCamelCase_ ...
147
1
'''simple docstring''' def SCREAMING_SNAKE_CASE ( a_ : int = 1000 ): __a = 2**power __a = 0 while n: __a , __a = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(str(input()).strip())))
703
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def SCREAMING_SNAKE_CASE ( a_ : Tuple ): # This defines a "chinese character" as anything in the CJK Unicode block: # https:/...
490
0
from __future__ import annotations def lowerCamelCase( a__): create_state_space_tree(a__ ,[] ,0 ,[0 for i in range(len(a__))]) def lowerCamelCase( a__ ,a__ ,a__ ,a__ ,): if index == len(a__): print(a__) return for i in range(len(a...
691
from typing import TYPE_CHECKING from ....utils import _LazyModule snake_case_ : Dict = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys snake_case_ : Union[str, Any] = ...
691
1
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __snake_case ( a ): UpperCAmelCase_...
169
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def A (__A : int ) -> bool: """simple docstring""" UpperCAmelCase_ = int(number**0.5 ) return number == sq * sq def A (__A : ...
169
1
'''simple docstring''' import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow a : Tuple = logging.getLogger() @unittest...
69
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Tuple = { '''huggingface/autoformer-tourism-monthly''': '''https:...
69
1
"""simple docstring""" import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order spe...
141
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_i...
141
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Dict = logging.get_logger(__name__) __A : str = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json' ), ...
16
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A_ : Optional[Any] = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBer...
265
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__ = { """distilbert-base-uncased""": """https://huggingf...
648
# 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 ap...
648
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __lowerCAmelCase ( _A ,_A ,_A ): """simple docstring""" _lowercase = OmegaConf.load(snake_case__ ) _lowercase = torch.load...
398
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 .....
67
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class __UpperCamelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self , UpperC...
704
import torch from diffusers import StableDiffusionPipeline UpperCAmelCase_ ="""path-to-your-trained-model""" UpperCAmelCase_ =StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") UpperCAmelCase_ ="""A photo of sks dog in a bucket""" UpperCAmel...
33
0
__snake_case = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _A ( _lowercase ) -> str: """simple docstring""" __UpperCamelCase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. ...
1
from __future__ import annotations import requests def _UpperCAmelCase (UpperCamelCase__ : str ): _A : List[Any] = f"https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty" return requests.get(UpperCamelCase__ ).json() def _UpperCAmelCase (U...
503
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is_torch_...
427
'''simple docstring''' import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state...
427
1
def SCREAMING_SNAKE_CASE ( lowercase_ = 1_000 ) -> int: """simple docstring""" return sum(e for e in range(3 , lowercase_ ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F'''{solution() = }''')
87
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance _lowerCamelCase : Dict = 6_378_137.0 _lowerCamelCase : Union[str, Any] = 6_356_752.314_245 _lowerCamelCase : List[Any] = 6378137 def SCREAMING_SNAKE_CASE ...
87
1
'''simple docstring''' from __future__ import annotations from math import pow, sqrt def UpperCamelCase ( lowercase_ : float , lowercase_ : float , lowercase_ : float ) -> dict[str, float]: '''simple docstring''' if (resistance, reactance, impedance).count(0 )...
145
'''simple docstring''' _UpperCAmelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def UpperCamelCase ( ) -> None: '''simple docstring''' lowercase =input('''Enter message: ''' ) lowercase =input('''Enter key [alphanumeric]: ''' ) lowercase =i...
145
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : int ) -> str: """simple docstring""" UpperCAmelCase_ : list[list[str]] = [[] for _ in range(_SCREAMING_SNAKE_CASE )] UpperCAmelCase_ : Any ...
71
from abc import ABC, abstractmethod from typing import List, Optional class _lowerCAmelCase ( __SCREAMING_SNAKE_CASE ): def __init__( self : List[Any] ): # test for the above condition self.test() def snake_case ( self : ...
166
0
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 import Be...
718
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from .....
17
0
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCamelCase ( snake_case_ ): '''simple docstring''' __lowercase : Union[str, Any] = '''ClapFeatureExtractor''' __lowercase : List[str] ...
365
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 #...
365
1
'''simple docstring''' import json import os from ...utils.constants import SAGEMAKER_PARALLEL_EC2_INSTANCES, TORCH_DYNAMO_MODES from ...utils.dataclasses import ComputeEnvironment, SageMakerDistributedType from ...utils.imports import is_botoa_available from .config_args import SageMakerConfig from .config_utils ...
702
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case : str = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', ...
339
0
'''simple docstring''' from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def __UpperCamelCase( _A : str , _A : float | Decimal , _A : float = 10**-10 ): '''simple docstring''' UpperCAmelCase_...
614
'''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 UpperCamelCase__ : Optional[Any] = logging.getLogger(__name__) Uppe...
614
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": __UpperCamelCase : Tuple = "%20".join(argv[1:]) if len(argv) > 1 else quote(str...
713
from math import factorial, radians def _a ( SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : int = 18 , SCREAMING_SNAKE_CASE : int = 10 ): """simple docstring""" UpperCamelCase__ : Dict = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Conve...
106
0
'''simple docstring''' from __future__ import annotations __SCREAMING_SNAKE_CASE : Optional[Any] =[ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : list[list[int]] , lowerCamelCase__ :...
135
'''simple docstring''' import math def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, ...
135
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCAmelCase ( snake_case )...
494
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrain...
494
1
'''simple docstring''' 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_mvp imp...
446
'''simple docstring''' import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from ....
446
1
import numpy as np import datasets A__ = """ 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. P. C. Mah...
49
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 ANY if is...
49
1
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, ) from...
147
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""", """VisionEncoderDec...
147
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _UpperCamelCase = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
363
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { 'huggingface/time-series-transformer-tourism-m...
363
1
"""simple docstring""" from collections.abc import Sequence def _snake_case ( _snake_case : Sequence[float] , _snake_case : bool = False ) -> float: '''simple docstring''' if not arr: return 0 _A = 0 if allow_empty_subarrays else ...
7
"""simple docstring""" import numpy as np def A__ ( __lowerCamelCase ): """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
589
0
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 numpy as np import tensorflow as tf from transformers import TFXLMRober...
708
def __UpperCAmelCase ( lowerCamelCase_ : int = 10_00 ) -> int: """simple docstring""" return sum(e for e in range(3 , lowerCamelCase_ ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"""{solution() = }""")
685
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer lowerCamelCase : Optional[Any] = logging.get_logger(__n...
170
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowercase__( A ): if "model" in orig_key: snake_case__ : Any = orig_key.replace('model.' , '' ) if "norm1" in orig_key: snake_case__ : Optional...
170
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : List[str] = { '''configuration_table_transformer''': [ '''TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TableTransformerConfig''', '''TableTransform...
711
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_=2 , snake_case_=3 , snake_case_=6_4 , snake_case_=Non...
527
0
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : int ): '''simple docstring''' _UpperCAmelCase : Any =1 for i in range(1 , num + 1 ): fact *= i return fact def lowerCamelCase__ ( __lowerCamelCase : int ): ...
446
'''simple docstring''' 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_available(): from PIL import Image fr...
446
1
"""simple docstring""" def _A (__a , __a ) -> Tuple: """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = len(_lowercase ) print('''The following activities are selected:''' ) # The first activity is always selected ...
718
"""simple docstring""" from math import isqrt def _A (__a ) -> list[int]: """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[Any] = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
176
0
from collections import defaultdict def SCREAMING_SNAKE_CASE_ ( _snake_case :List[str] , _snake_case :str ) -> bool: _A = first_str.lower().strip() _A = second_str.lower().strip() # Remove whitespace _A = first_str.replace(''' ''' , ''''''...
2
from collections import defaultdict def _a ( lowerCAmelCase , lowerCAmelCase )-> bool: SCREAMING_SNAKE_CASE_ = first_str.lower().strip() SCREAMING_SNAKE_CASE_ = second_str.lower().strip() # Remove whitespace SCREAMING_SNAKE_CASE_ ...
360
0
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) lowercase__ = str(bin(SCREAMING_SNAKE_CASE_ ) )[2:] # remove the leading "0b" lowercase__ = str(bin(SCREAMING_SNA...
37
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase_ = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MA...
37
1
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def _lowerCAmelCase ( lowercase , lowercase , lowercase , lowercase , lowercase ) -> Dict: # load base model __lowe...
689
"""simple docstring""" from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollato...
155
0
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> list[int]: SCREAMING_SNAKE_CASE__ : Optional[int] = 0 SCREAMING_SNAKE_CASE__ : Any = len(__lowerCAmelCase ) - 1 whi...
12
"""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 ...
12
1
"""simple docstring""" from maths.prime_check import is_prime def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> int: if not isinstance(_lowerCamelCase ,_lowerCamelCase ): _lowerCAmelCase : List[str] = f"Input value of [number={number}] must be an integer" rai...
213
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _a : int = get_tests_dir('fixtures/test_sentencepiece_...
213
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _A = TypeVar('T') class _lowercase ( Generic[T] ): def __init__( self , UpperCAmelCase_ ) -> str: lowerCamelCase : ...
719
"""simple docstring""" from copy import deepcopy class _lowercase : def __init__( self , UpperCAmelCase_ = None , UpperCAmelCase_ = None ) -> None: if arr is None and size is not None: lowerCamelCase : Any = size lowerCamelCase : Op...
133
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
12
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, 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, rand...
614
0
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common im...
708
from __future__ import annotations def _lowerCamelCase ( snake_case ): _lowerCAmelCase = len(snake_case ) # We need to create solution object to save path. _lowerCAmelCase = [[0 for _ in range(snake_case )] for _ in range(snake_case )] _lo...
225
0
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, RandomS...
524
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
321
0
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency a_ : List[str] = { 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, 'C': 2.78, 'U': 2.76, ...
148
import argparse from collections import defaultdict import yaml a_ : Tuple = 'docs/source/en/_toctree.yml' def __a ( __UpperCAmelCase ): a__ = defaultdict(__UpperCAmelCase ) a__ = [] a__ = [] for doc in doc_list: if "local" in doc: ...
148
1
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 import BertCo...
487
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature ...
487
1
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins _lowerCAmelCase = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def UpperCamelCase ( a , a ) -> Optional[Any]: '''simple docstring''' fo...
720
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCAmelCase = logging.get_logger(__nam...
245
0
'''simple docstring''' 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_...
11
'''simple docstring''' def __snake_case ( lowerCAmelCase : str ): if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) __UpperCAmelCase = sorted(string.lower() ) return len(lowerCAmelCase ) == le...
396
0
SCREAMING_SNAKE_CASE__ = { 0: """0""", 1: """1""", 2: """2""", 3: """3""", 4: """4""", 5: """5""", 6: """6""", 7: """7""", 8: """8""", 9: """9""", 1_0: """a""", 1_1: """b""", 1_2: """c""", 1_3: """d""", 1_4: """e""", 1_5: """f""", } def S...
601
from __future__ import annotations SCREAMING_SNAKE_CASE__ = tuple[int, int, int] SCREAMING_SNAKE_CASE__ = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase SCREAMING_SNAKE_CASE__ = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" # --------------------...
601
1
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo __SCREAMING_SNAKE_CASE : str ='\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human an...
135
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 PreTrainedTokenizerBase def ...
43
0
'''simple docstring''' import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class UpperCAmelCase_ ( __A ): ...
718
'''simple docstring''' from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_t...
8
0
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def A__ ( ) -> List[str]: A , A : Optional[Any] =9, 14 # noqa: F841 A : Optional[Any] =[ [0, 1, 4], [0, 7, 8], [1, 2, ...
305
from __future__ import annotations def A__ ( lowercase: int | str ) -> bool: A : int =str(lowercase ) return n == n[::-1] def A__ ( lowercase: int = 1_000_000 ) -> Any: A : str =0 for i in range(1, lowercase ...
305
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_ext...
460
'''simple docstring''' def _snake_case ( A_ : list ): """simple docstring""" if len(A_ ) <= 1: return [tuple(A_ )] a_ : List[Any] = [] def generate(A_ : int , A_ : list ): a_ : List[Any] = [0]...
460
1
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def UpperCAmelCase ( snake_case : int , snake_case : Any , snake_case : ...
227
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = OrderedDict( [ # Base mod...
326
0
"""simple docstring""" import functools def _snake_case ( lowercase__ : str , lowercase__ : str ) -> int: '''simple docstring''' lowerCAmelCase_ :int = len(lowercase__ ) lowerCAmelCase_ :List[str] = len(lowerca...
256
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( ...
256
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int = 4_00_00_00 ) -> int: """simple docstring""" UpperCAmelCase_ : Optional[Any] = [0, 1] UpperCAmelCase_ : Optional[Any] = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + ...
71
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BlipCon...
191
0
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
45
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class SCREAMING_SNAKE_CASE (UpperCAmelCase ): def __init__( ...
45
1
'''simple docstring''' def a_ ( _lowerCAmelCase=28123 ) -> Union[str, Any]: __lowerCamelCase : Any = [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 ): sum_divs[k * i] += ...
459
'''simple docstring''' import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_availab...
459
1
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json'...
322
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, D...
322
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: lower...
462
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast 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 TokenizerTeste...
670
0
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer a =...
505
"""simple docstring""" a = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' a = [{'''...
505
1
"""simple docstring""" import random class SCREAMING_SNAKE_CASE__ : @staticmethod def _UpperCAmelCase ( lowerCAmelCase_ : str): """simple docstring""" lowercase_ = [ord(lowerCAmelCase_) for i in text] lo...
567
"""simple docstring""" from math import factorial UpperCAmelCase : Tuple = {str(d): factorial(d) for d in range(10)} def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(__lowerCAmelCa...
567
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_ena...
511
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate i...
511
1
def __a ( __lowerCAmelCase , __lowerCAmelCase ) -> str: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) SCREAMING_SNAKE_CASE : int = str(bin(__lowerCAmelCase ) )[2:] # remove the leading "0b" SCRE...
352
def __a ( __lowerCAmelCase , __lowerCAmelCase = 0 ) -> list: SCREAMING_SNAKE_CASE : int = length or len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE : Union[str, Any] = False for i in range(length - 1 ): if list_data[i] > ...
352
1
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multipl...
717
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multipl...
431
0
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def __lowerCamelCase ( _Up...
390
'''simple docstring''' from math import loga def __lowerCamelCase ( _UpperCamelCase : int ): '''simple docstring''' if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(_UpperCamelCase , _UpperCamelCase ): ...
390
1
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets _A : Union[str, Any] = """\ @inproceedings{snover-etal-2006-study, title = \"A Study of Translation Edit Rate with Targeted Human Annotation\", author = \"Snover, M...
700
"""simple docstring""" from math import factorial _A : dict[str, int] = {str(digit): factorial(digit) for digit in range(10)} def __magic_name__ ( __snake_case : int ) -> int: if not isinstance(__snake_case , __snake_case ): raise ...
518
0
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequence...
353
'''simple docstring''' import unittest from knapsack import knapsack as k class __lowerCamelCase ( unittest.TestCase ): '''simple docstring''' def a_ ( self ): __SCREAMING_SNAKE_CASE : Tuple = 0 __SCREAMIN...
211
0
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCAmelCase__ = Lock() def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , ...
708
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipel...
6
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Tuple = logging.get_logger(__name__) A_ : Optional[int] = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class lo...
265
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor lowerCAmelCase__ = logging.get_logger(__name__) class lowercase_ (lowerCamelCase__ ): """simple docstring""" def __init__( self : List[Any] ,*low...
41
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INP...
705
from __future__ import annotations from math import pi, sqrt def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> tuple: """simple docstring""" if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif...
219
0
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 FlaxModelTesterMixin, floats_tensor if i...
371
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs i...
211
0
'''simple docstring''' import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset ...
517
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def __lowerCamelCase ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : int , __lower...
517
1
'''simple docstring''' from __future__ import annotations __snake_case : Tuple = list[tuple[int, int]] __snake_case : Any = [ [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, 1, 0, 0, 0, 0], [1, 0, 1, ...
660
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __snake_case : Union[str, Any] = {'''configuration_plbart''': ['''PLBART_PRETRAINED_C...
660
1
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): return credit_card_number.startswith(('34', '35', '37', '4', '5', '6') ) def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Dict = credit_card_number __lowerCamelCase : Tuple = 0 __lowerCamelCase : ...
230
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { 'configuration_deberta': ['DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DebertaConfig', 'DebertaOnnxConfig'...
230
1
'''simple docstring''' import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) lowercase__ ...
638
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase__ = TypeVar("T") class snake_case__ ( Generic[T] ): """simple docstring""" def __init__( se...
638
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__UpperCAmelCase ) class UpperCAmelCase__ ( __UpperCAmelCase ): lowerCAmelCase_ ...
710
'''simple docstring''' import math def A_ ( _lowerCAmelCase : int ): """simple docstring""" _lowerCamelCase : Optional[int] = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_lowerCAmelCase ) ...
11
0
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def __snake_case ( __A ) -> Union[str, Any]: # This defines a "chinese character" as anything in the C...
607
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): ...
607
1
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device fr...
283
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_bi...
283
1
from math import isclose, sqrt def lowerCamelCase_ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): A_ = point_y / 4 / point_x A_ = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) A_ = (1 - normal_gradient * normal_gr...
141
'''simple docstring''' import argparse import json from tqdm import tqdm def _snake_case ( ) -> Optional[int]: """simple docstring""" lowerCAmelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( """--src_path...
433
0
def _snake_case ( __snake_case ) -> int: '''simple docstring''' assert column_title.isupper() UpperCAmelCase_ : int = 0 UpperCAmelCase_ : str = len(__snake_case ) - 1 UpperCAmelCase_ : str = 0 while index >= 0: ...
715
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_roformer''': ['''ROFORMER_PRETRAINED_CONFIG_ARCHIVE_M...
455
0
import qiskit def __a ( __UpperCAmelCase : int , __UpperCAmelCase : int ) -> qiskit.result.counts.Counts: """simple docstring""" lowerCamelCase_ : Any = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acti...
488
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(): import jax...
488
1
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) def lowerC...
367
UpperCAmelCase_ : int = [ 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, ] ...
367
1
'''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 : Union[str, Any] = logging.get_logger(__name__) _a ...
56
'''simple docstring''' import math def a ( _UpperCAmelCase ) -> bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers...
697
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCAmelCase = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if ...
251
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging __UpperCAmelCase = logg...
251
1
"""simple docstring""" from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase (a_ :str) -> Dict: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code) class __magic_name__ ...
677
"""simple docstring""" import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
677
1
def _A( UpperCamelCase__ : int ) -> bool: '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("Program to check whether a number is a Perfect number or not...") UpperCAm...
362
import math def _A( ) -> None: '''simple docstring''' __lowercase = input('''Enter message: ''' ) __lowercase = int(input(F'Enter key [2-{len(UpperCamelCase__ ) - 1}]: ' ) ) __lowercase = input('''Encryption/Decryption [e/d]: ''' ...
362
1
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers impo...
661
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __SCREAMING_SNAKE_CASE : str = tuple[int, int] class lowerCamelCase_: '''simple docstring''' def __init__( self , lowerCamelCase__ , lowerCamelCase__...
661
1
"""simple docstring""" import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_in...
16
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { """vocab_file""": """vocab.j...
16
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from tr...
74
'''simple docstring''' from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def _UpperCamelCase ( UpperCamelCase__ ): if not is_accelerate_available(): return method UpperCAmelC...
407
0
'''simple docstring''' from math import loga def __snake_case ( lowercase : int ): if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(lowercase , lowercase ): raise TypeError("Input value must be a 'int' type...
420
'''simple docstring''' import os from pathlib import Path def __snake_case ( ): from torch.utils.cpp_extension import load snake_case_ = Path(lowercase ).resolve().parent.parent.parent / "kernels" / "deformable_detr" snake_case_ = [ root / filename for f...
420
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: Dict , UpperCamelCase__: Optional[Any]=None ): SCREAMING_SNAKE_CASE__ = None ...
6
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import l...
86
0
import pprint import requests UpperCAmelCase_ : int = """https://zenquotes.io/api""" def _lowerCAmelCase ( ) -> int: return requests.get(API_ENDPOINT_URL + """/today""" ).json() def _lowerCAmelCase ( ) -> Dict: return requests.get(API_ENDPOINT_URL + ...
711
# 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 app...
440
0
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet impor...
147
from __future__ import annotations class lowerCamelCase_ : def __init__( self , lowerCamelCase_ , lowerCamelCase_ ) -> int: """simple docstring""" _UpperCamelCase , _UpperCamelCase = text, pattern _UpperCamelCase , _UpperCamelCase =...
147
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class UpperCamelCase ( SCREAMING_SNAKE_CASE ): __UpperCame...
673
def __lowerCAmelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE = abs(_UpperCamelCase ) SCREAMING_SNAKE_CASE = 0 while n > 0: res += n % 10 n //= 10 return res def __lowerCAmelCase ( _UpperCamelCase : int ) -...
673
1
from math import factorial, radians def A ( __UpperCamelCase , __UpperCamelCase = 18 , __UpperCamelCase = 10 ) -> float: A__ = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radians A__ = radians(__UpperCamelCase ...
9
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as...
450
0
import numpy as np def A_ ( A__ ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
718
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A__ ( __UpperCAmelCase ): """simple docstring""" __A : Tuple = ['''image_processor''', '''tokenizer'''] __A : Any = ...
392
0
"""simple docstring""" def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase ) -> str: if not (isinstance(__UpperCAmelCase , __UpperCAmelCase ) and isinstance(__UpperCAmelCase , __UpperCAmelCase )): raise ValueError("""longest_common_substring() ta...
299
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mo...
299
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github _a : int= [ "good first issue", "feature request", "wip", ] def __UpperCAmelCase ( ) -> List[str]: '''simple docstring''' __snake_case ...
192
"""simple docstring""" import string import numpy def __UpperCAmelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: '''simple docstring''' return b if a == 0 else greatest_common_divisor(b % a , UpperCAme...
192
1