code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
def __snake_case ( _UpperCamelCase ) -> int: if not numbers: return 0 if not isinstance(_UpperCamelCase , (list, tuple) ) or not all( isinstance(_UpperCamelCase , _UpperCamelCase ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) ...
487
lowerCamelCase :Optional[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } def __snake_case ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list[s...
487
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case = { "configuration_poolformer": [ "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PoolFormerConfig", "PoolFormerOnnxConfig", ...
700
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class SCR...
488
0
"""simple docstring""" def _snake_case ( __snake_case : int = 10**9 ): """simple docstring""" _lowerCamelCase : Any = 1 _lowerCamelCase : int = 2 _lowerCamelCase : Tuple = 0 _lowerCamelCase : Any = 0 _lowerCamelCa...
88
"""simple docstring""" from __future__ import annotations import queue class lowercase__ : def __init__( self , SCREAMING_SNAKE_CASE) -> int: _lowerCamelCase : int = data _lowerCamelCase : List[str] = None _lowerCamelCase : Any ...
88
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { '''...
707
def __magic_name__ ( lowerCAmelCase_ = "The quick brown fox jumps over the lazy dog" , ): '''simple docstring''' lowerCamelCase_ : Any = set() # Replace all the whitespace in our sentence lowerCamelCase_ : str = input_str.replace(" " ...
73
0
def lowercase ( _lowerCAmelCase = 6008_5147_5143 ): try: UpperCAmelCase__ = int(_lowerCAmelCase ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: raise ValueError("""Parameter n must be greater than or...
392
def lowercase ( _lowerCAmelCase ): UpperCAmelCase__ = len(_lowerCAmelCase ) while cur > 1: # Find the maximum number in arr UpperCAmelCase__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi UpperCAmelCase__ = arr[mi::-1] + arr[mi + 1 : len(_...
392
1
'''simple docstring''' def UpperCAmelCase ( lowerCAmelCase__ ): '''simple docstring''' assert column_title.isupper() __A = 0 __A = len(lowerCAmelCase__ ) - 1 __A = 0 while index >= 0: __A = (ord(colum...
701
class a__ : def __init__( self ) -> str: __A = 0 __A = 0 __A = {} def _lowerCamelCase ( self , lowercase__ ) -> List[Any]: if vertex not in self.adjacency: _...
205
0
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> int: return abs(_UpperCAmelCase ) if a == 0 else greatest_common_divisor(b % a , _UpperCAmelCase ) def __UpperCAmelCase ( _UpperCAmelCase : int , _Uppe...
69
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import ...
688
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class __lowerCamelCase ( UpperCamelCase__ , un...
125
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def _A ( ): """simple docstring""" lowerCAmelCase__ = [randint(-1000 , 1000 ) for i in range(10 )] lowerCAmelCase__ ...
125
1
'''simple docstring''' from sklearn.metrics import mean_squared_error import datasets SCREAMING_SNAKE_CASE__ = "\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thi...
267
'''simple docstring''' SCREAMING_SNAKE_CASE__ = 256 # Modulus to hash a string SCREAMING_SNAKE_CASE__ = 100_0003 def lowerCamelCase ( _snake_case : str ,_snake_case : str ): '''simple docstring''' lowercase__ = ...
267
1
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CAS...
48
"""simple docstring""" import argparse import copy def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : Any ): """simple docstring""" snake_case_ : List[Any] = {} with open(SCREAMING_SNAKE_CASE__ ) as f: for line in f: if line...
48
1
'''simple docstring''' import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging a__ : List[str] ...
368
'''simple docstring''' import os from math import logaa def __magic_name__ ( __UpperCAmelCase = "base_exp.txt" ) -> int: '''simple docstring''' __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 for i, line in enumerate(open(os.path.join(os....
109
0
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_available(): from ..onnx_utils import OnnxRuntimeModel f...
626
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch i...
626
1
import comet # From: unbabel-comet import torch import datasets _lowerCamelCase = datasets.logging.get_logger(__name__) _lowerCamelCase = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon},\n title ...
114
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCame...
114
1
"""simple docstring""" from typing import List import numpy as np def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = {key: len(UpperCamelCase_ ) for key, value in gen_kwargs.items() if isinstance(UpperCamelCase_ , UpperCamelCase_ )} if len(set...
248
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): return int((input_a, input_a).count(0 ) == 0 ) def _lowerCAmelCase ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 ...
248
1
"""simple docstring""" def lowerCAmelCase_ ( snake_case_ : int ) ->bool: return str(snake_case_ ) == str(snake_case_ )[::-1] def lowerCAmelCase_ ( snake_case_ : int ) ->int: return int(snake_case_ ) + int(str(snake_case_ )[::-1] ...
174
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from ...
174
1
"""simple docstring""" import numpy as np def snake_case__ ( _lowerCamelCase ) ->np.array: """simple docstring""" return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
281
"""simple docstring""" from scipy.stats import spearmanr import datasets __A : Optional[int] = '\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no ...
281
1
"""simple docstring""" from __future__ import annotations def a__ ( snake_case__ ) -> int: if not nums: return 0 lowerCamelCase = nums[0] lowerCamelCase = 0 for num in nums[1:]: lowerCamelCase , lowerCamelCase = ( max_excludin...
543
"""simple docstring""" def a__ ( snake_case__ = 50_00_00_00 ) -> int: lowerCamelCase = set() lowerCamelCase = int((limit - 24) ** (1 / 2) ) lowerCamelCase = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ...
543
1
from __future__ import annotations _lowerCAmelCase = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"""], } class ...
481
from typing import List from .keymap import KEYMAP, get_character def _lowerCAmelCase ( _lowerCAmelCase ): '''simple docstring''' def decorator(_lowerCAmelCase ): A_ : List[Any] = getattr(_lowerCAmelCase ,"""handle_key""" ,[] ) handle += [key] setat...
481
1
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ) -> Dict: lowercase__ : Optional[int...
560
"""simple docstring""" import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models...
560
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowercase : Union[str, Any] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): '''simple docstring''' def __init__...
704
"""simple docstring""" 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 imp...
625
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
445
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 RobertaTokenizer sn...
445
1
from __future__ import annotations from functools import lru_cache from math import ceil lowerCamelCase_ : Dict = 100 lowerCamelCase_ : Any = set(range(3, NUM_PRIMES, 2)) primes.add(2) lowerCamelCase_ : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: ...
246
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__snake_case ) class a__ ( __snake_case ): # `task` is not a ClassVar since we want it to be part of the `asdict` output...
246
1
"""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 acce...
139
"""simple docstring""" from __future__ import annotations import pandas as pd def lowerCamelCase ( _UpperCamelCase : list[int] , _UpperCamelCase : list[int] , _UpperCamelCase : int ) -> list[int]: '''simple docstring''' __UpperCAmelCase : List[Any] ...
139
1
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun...
85
"""simple docstring""" from ....utils import logging a : List[str] = logging.get_logger(__name__) class __UpperCAmelCase( SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self , snake_case__ , ...
85
1
def __snake_case ( lowerCAmelCase_ = 1_0_0 ) -> int: SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ ...
100
'''simple docstring''' import os def _snake_case ( ): """simple docstring""" with open(os.path.dirname(A_ ) + """/grid.txt""" ) as f: a_ : Dict = [] # noqa: E741 for _ in range(20 ): l.append([int(A_ ) for x in f.readline().split()] ) ...
577
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase__ = { "configuration_groupvit": [ "GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GroupViTConfig", "GroupViTOnnxConfig", "GroupV...
639
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_vision_avai...
639
1
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 __UpperCamelCase ( A ...
415
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 import Decoder, DecoderOut...
306
0
"""simple docstring""" snake_case = 'Input must be a string of 8 numbers plus letter' snake_case = 'TRWAGMYFPDXBNJZSQVHLCKE' def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_ ): if not isinstance(_SCREAMING_SNAKE_CASE, _SCREAMING_SNAKE_CASE ): SCREAMING_SNAK...
702
"""simple docstring""" snake_case = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_ ): SCREAMING_SNAKE_CASE = 0 while number: # Increased Speed Slightly by checking every 5 digits toge...
406
0
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute...
328
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_im...
328
1
"""simple docstring""" from __future__ import annotations def lowercase (snake_case__ : dict , snake_case__ : str ) -> set[str]: '''simple docstring''' lowerCAmelCase , lowerCAmelCase = set(snake_case__ ), [start] while stack: lowerCA...
529
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase (snake_case__ : dict , snake_case__ : str , snake_case__ : set , snake_case__ : set , snake_case__ : dict , snake_c...
529
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Optional[int] = { "configuration_longformer": [ "LO...
564
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Union[str, Any] = {"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]} try: if no...
564
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 __lowerCAmelCase : Tuple = logging.get_logger(__name...
704
"""simple docstring""" import math import tensorflow as tf from packaging import version def __lowerCAmelCase ( __UpperCamelCase : List[Any] ): '''simple docstring''' snake_case_ : int = tf.convert_to_tensor(__UpperCamelCase ) sna...
21
0
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets _lowercase = '\\n@inproceedings{snover-etal-2006-study,\n title = "A Study of Translation Edit Rate with Targeted Human Annotation",\n author = "Snover, Matthew and\n Dorr, Bonnie and\n ...
306
'''simple docstring''' class _UpperCamelCase : '''simple docstring''' def __init__( self , _a ): """simple docstring""" # we need a list not a string, so do something to change the type a__ = arr.split(',' ) ...
394
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ : int = { "configuration_maskformer": ["MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "MaskFormerConfig"], "configuration_mask...
709
'''simple docstring''' import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoCon...
419
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
6
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) class UpperCamelCase_ ( UpperCamelCase__ ): lowerCamelCase_ = "encoder-decoder" lowerCamelCase_ = ...
6
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 lowerCAmelCase__ : List[str] = logging.get_logger(_...
502
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
502
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """distilbert-base-uncased""": """https://huggi...
306
"""simple docstring""" import re import string import numpy as np import datasets a__ : Dict = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ a__ : List[str] ...
589
0
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = len(_A ) lowercase__ = [[0] * n for i in range(_A )] for i in range(_A ): lowercase__ = y_points[i] for i in range(2 , ...
719
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _a ( unittest.TestCase ): def lowerCamelCase_ ( self: int ) -> None: """simple docstring...
429
0
'''simple docstring''' 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 import BertTokenizer UpperCAmelCase_ : int = log...
24
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig 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 impo...
276
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """camembert-base""": """https://huggingface.co/camembert...
488
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
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : List[str] = { '''configuration_xlm_roberta_xl''': [ '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMRobertaXLConfig''', ...
72
'''simple docstring''' import unittest import numpy as np def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray | None = None ...
603
0
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from tr...
463
"""simple docstring""" lowerCamelCase_ = { '''a''': '''AAAAA''', '''b''': '''AAAAB''', '''c''': '''AAABA''', '''d''': '''AAABB''', '''e''': '''AABAA''', '''f''': '''AABAB''', '''g''': '''AABBA''', '''h''': '''AABBB''', '''i''': '''ABAAA''', '''j''': '''BBBAA''',...
463
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Dict = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { '''microsoft/unispeech-sat-base...
4
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, 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...
52
0
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 TFMod...
321
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...
321
1
def _A ( __snake_case :str ) -> List[Any]: """simple docstring""" return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def _A ( __snake_case :str ) -> Any: """simple docstring""" __SCREAMING_SNAKE_CASE = ...
693
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig...
200
0
'''simple docstring''' 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_PARA...
713
'''simple docstring''' from typing import Any class a : '''simple docstring''' def __init__( self , lowerCamelCase_ ) -> Dict: _a : int = data _a : Any = None def __repr__( self ) -> str: return F'''Node({self....
424
0
'''simple docstring''' from collections import deque class lowercase_ : """simple docstring""" def __init__( self : Tuple, UpperCamelCase__ : str, UpperCamelCase__ : int, UpperCamelCase__ : int ) -> None: _A = process_name # process...
107
'''simple docstring''' # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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 # ...
495
0
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _snake_case : Any = collections.namedtuple('_Dataset...
214
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _A ( ) -> Optional[int]: """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename ...
214
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass ...
29
'''simple docstring''' import flax.linen as nn import jax import jax.numpy as jnp class A ( nn.Module ): lowerCamelCase : int lowerCamelCase : jnp.dtype = jnp.floataa def A__ ( self ) -> List[Any]: '''simple docstring''' ...
325
0
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : int = 10 ) -> str: """simple docstring""" if not isinstance(__A ,__A ) or n < 0: raise ValueError('Invalid input' ) SCREAMING_SNAKE_CASE_ : st...
708
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class lowerCAmelCase_ ( __A ): '''simple docstring''' def __init__( self , *__UpperCAmelCase , **_...
153
0
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_...
57
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch i...
606
0
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, requi...
452
import qiskit def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Dict = qiskit.Aer.get_backend('''aer_simulator''' ) __UpperCamelCase :Tuple = qiskit.QuantumCircuit(4 , 2 ) # encode in...
452
1
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTester...
302
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 RobertaTokenizer ...
302
1
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) a = { "io...
175
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(): import torch a ...
175
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : List[str] = logging.get_logger(__name__) __lowerCamelCase : Optional[Any] = { "microsoft/git-base": "https://huggingface.co/microsoft/git...
323
'''simple docstring''' import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_commo...
446
0
'''simple docstring''' import math from datetime import datetime, timedelta def __UpperCamelCase ( a : int ) ->datetime: snake_case = year % 19 snake_case = year % 4 snake_case = year % 7 snake_case = math.floor(year / 100 ) snake_case = ma...
707
'''simple docstring''' from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available ...
44
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example _a : Union[str, Any] = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0...
56
def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> str: '''simple docstring''' return "\n".join( F'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5...
472
0
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase :...
703
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _A ( lowerCAmelCase ): snake_case__ : Union[str, Any] = (IPNDMScheduler,) snake_case__ : List[...
197
0
from __future__ import annotations from typing import Generic, TypeVar _snake_case = TypeVar("T") class UpperCAmelCase_ ( Generic[T]): def __init__( self, __a): '''simple docstring''' _lowerCAmelCase : Dict = data ...
500
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ,unittest.TestCase ): _UpperCAmelCase : Dict = Dow...
315
0
from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' def __init__( self : Optional[Any]) -> Optional[Any]: """simple docstring""" self.test() def UpperCAmelCase ( ...
642
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__( lowerCamelCase ): '''simple docstring''' A : List[Any] ...
642
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
328
# 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 # # U...
328
1
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @s...
706
'''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 snake_case = logging.getLogger(__name__) snake_case = ...
568
0
"""simple docstring""" def __A ( a_ :int) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
52
"""simple docstring""" 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_NAM...
52
1
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax i...
717
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) class ...
238
0
"""simple docstring""" def __snake_case ( _lowercase ): """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
34
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass ...
590
0
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class UpperCamelCase__ ( lowercase__ ): def __init__( self : Optional[int] , *lowerCamelCase : Optional[Any] , **lowerCamelCase : str ): '''s...
715
'''simple docstring''' import math def _lowerCamelCase (__lowerCamelCase : list , __lowerCamelCase : int = 0 , __lowerCamelCase : int = 0 ) -> list: a__ = end or len(__lowerCamelCase ) for i in range(__lowerCamelCase , __lowerCam...
289
0
"""simple docstring""" from sklearn.metrics import fa_score import datasets _SCREAMING_SNAKE_CASE : List[str] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall)...
549
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test...
549
1
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, Wava...
250
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(): import torch a_ :Optional[Any] ...
250
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
44
import numpy as np from PIL import Image def snake_case__ ( UpperCAmelCase : np.ndarray , UpperCAmelCase : int , UpperCAmelCase : int ): lowerCAmelCase__ :Union[str, Any] = np.array(UpperCAmelCase ) if arr.shape[0] != arr.shape[1]: rai...
145
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandin...
121
"""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
1
from __future__ import annotations def _UpperCAmelCase ( A , A ): '''simple docstring''' if len(A ) < k or k < 0: raise ValueError("Invalid Input" ) UpperCAmelCase__ =UpperCAmelCase__ =sum(array[:k] ) for i in range(le...
625
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase_ = { 'configuration_owlvit':...
625
1
"""simple docstring""" import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from trans...
714
"""simple docstring""" import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( "kwargs, expected" , [ ({"num_shards": 0, "max_num_jobs": 1}, []), ({"num_shards": 10, "max_num_jobs": 1...
518
0
"""simple docstring""" import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuratio...
690
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ : Dict = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Graphormer...
442
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ : Optional[Any] = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """P...
208
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jn...
208
1
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 UpperCamelCase__ ( unittest.TestCase ):...
521
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCondit...
521
1
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def __a ( _lowercase , _lowercase = "cpu" , _lowercase = None ): """simple docstring""" lowerCamelCase__ : str = torch.load(_lowercase , map...
121
"""simple docstring""" import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTest...
121
1
"""simple docstring""" from maths.prime_factors import prime_factors def lowerCamelCase_ (UpperCamelCase__ : int ): if not isinstance(UpperCamelCase__ , UpperCamelCase__ ): _UpperCAmelCase : str = F'Input value of [number={number}] must be an integer' ...
506
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _lowerCAmelCase :Tuple = logging.get_logger(__name__) _lowerCAmelCase :Union[str, Any] = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-larg...
506
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Union[str, Any] =logging.get_logger(__name__) _UpperCAmelCase : Dict ={ """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/re...
619
def lowerCAmelCase ( lowerCAmelCase_ = 1_000_000 )-> int: lowerCAmelCase_ : Dict = 1 lowerCAmelCase_ : List[Any] = 1 lowerCAmelCase_ : Optional[Any] = {1: 1} for inputa in range(2 , lowerCAmelCase_ ): lowerCAmelCase_ : Tuple = ...
619
1
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __UpperCAmelCase ( a_: str = "isbn/0140328726" ): _UpperCAmelCase : Optional[int] = olid.strip().strip("/" ) # Remove leading/trailing whitespac...
494
'''simple docstring''' from __future__ import annotations def __UpperCAmelCase ( a_: str ): return [ord(a_ ) - 96 for elem in plain] def __UpperCAmelCase ( a_: list[int] ): return "".join(chr(elem + 96 ) for elem in encoded ) def __UpperCAmelCase ...
494
1
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 10_00 ): """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3, n + 1 ) ) if __name__ == "__main__": print(solution())
710
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_ch...
285
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling...
237
'''simple docstring''' from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _A ( __lowercase ): def lowercase__ ( self : Any ) -> str: """simple docstring""" return [ ...
26
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, EfficientForme...
629
from __future__ import annotations from random import random class __lowerCAmelCase : def __init__( self , snake_case = None ) -> Any: """simple docstring""" a__ : Optional[int] = value a__ : Tuple = random() a__ : Node...
629
1
from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCamelCase ( ): '''simple docstring''' __snake_case :Dict = ArgumentParser("""Diffusers CLI tool""" ,usage="""diffusers-cli <command> [<args>]""" ) ...
455
lowerCamelCase__ = 8.3_1_4_4_5_9_8 def UpperCamelCase ( snake_case__ : float ,snake_case__ : float ): '''simple docstring''' if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_mass <=...
455
1
"""simple docstring""" import unittest from transformers import XLMConfig, 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 impo...
700
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", ...
282
0
def __UpperCamelCase ( lowerCAmelCase__ : str ): if n_term == "": return [] __a : list = [] for temp in range(int(lowerCAmelCase__ ) ): series.append(f"1/{temp + 1}" if series else '''1''' ) return series if __name__ == "__main__": lowercase__ ...
521
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase__ ={ 'configuration_funnel': ['FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FunnelConfig'], 'convert_funnel_or...
521
1
"""simple docstring""" from sklearn.metrics import fa_score import datasets __lowercase = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ __lowercase ...
135
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_availa...
135
1
'''simple docstring''' from __future__ import annotations def A_( A : int , A : int): if b == 0: return (1, 0) ((UpperCamelCase) , (UpperCamelCase)) = extended_euclid(A , a % b) UpperCamelCase = a // b retur...
3
'''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, ) if is_sentencepiece_available(): ...
3
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Optional[int] = { '''configuration_blenderbot''': [ ...
647
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
647
1
# 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 req...
469
from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json", } class __low...
469
1
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCAmelCase( ): '''simple docstring''' import os as original_os from os import path as original_path from os import rename a...
426
'''simple docstring''' import fire from utils import calculate_rouge, save_json def lowerCAmelCase( a__ : List[str] , a__ : str , a__ : List[Any]=None , **a__ : Optional[Any] ): '''simple docstring''' lowerCamelCase__ ...
426
1
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 : str = logging.get_logger(__name__) A : Tuple = '''...
176
def __lowerCamelCase ( __a :Dict ) -> Optional[int]: """simple docstring""" A__ = [] A__ = [] A__ = { """^""": 3, """*""": 2, """/""": 2, """%""": 2, """+""": 1, """-""": 1, } # Priority of each o...
176
1
'''simple docstring''' import unittest from knapsack import knapsack as k class snake_case ( unittest.TestCase ): """simple docstring""" def snake_case ( self ): """simple docstring""" lowerCamelCase_ = 0 lowerCam...
445
'''simple docstring''' def __snake_case ( UpperCAmelCase_ : int = 1000 ): return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
445
1
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY...
335
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets snake_case : str = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and Singh, Aman...
335
1
"""simple docstring""" def a__ ( snake_case__ ) -> list[list]: lowerCamelCase = current_set.copy() for row_index, row in enumerate(snake_case__ ): lowerCamelCase = row[0] for column_index, column in enumerate(snake_case__ ): ...
533
"""simple docstring""" # A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v...
533
1
"""simple docstring""" import argparse import os 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_task_guides.py SCREAMING_SNAKE_CASE_ = '''src/transforme...
373
"""simple docstring""" import math def lowercase__ ( lowerCAmelCase : str , lowerCAmelCase : Optional[Any] ) -> List[Any]: """simple docstring""" if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the...
373
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example _SCREAMING_SNAKE_CASE = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
56
'''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, ) _SCREAMING_SNAKE_CASE ...
56
1
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _lowerCAmelCase ( unittest.TestCase ): def _a ( self ) -> Optional[Any]: _Uppe...
657
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unle...
657
1
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping A: Union[str, Any] = tuple[int, int] class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> None: '''simple...
359
"""simple docstring""" import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class SCREAMING_SNAKE_CASE__ ( Upp...
359
1
"""simple docstring""" # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar __A = TypeVar('''T''') class _snake_case ( Generic[T] ): def __init__...
646
"""simple docstring""" from manim import * class _snake_case ( a__ ): def lowerCamelCase__ ( self : str ): __lowerCamelCase : Tuple = Rectangle(height=0.5 , width=0.5 ) __lowerCamelCase : Dict = Rectangle(height=...
646
1
'''simple docstring''' class __lowercase : def __init__( self , UpperCamelCase ) -> None: __a = size __a = [0] * size __a = [0] * size @staticmethod def UpperCamelCase__ ( UpperCamelCase ) ...
709
'''simple docstring''' import numpy as np import datasets UpperCAmelCase_ = "\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean dis...
490
0