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 unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase__( __UpperCamelCase: Tuple ): """simple docstring""" return x + 2 class ...
28
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt_objects impo...
100
0
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCAmelCase__ ( lowerCamelCase_ : int ): def is_in_circle(lowerCamelCase_ : float , lowerCamelCase_ : float ) -> b...
707
def UpperCAmelCase__ ( lowerCamelCase_ : int = 3 , lowerCamelCase_ : int = 7 , lowerCamelCase_ : int = 1_0_0_0_0_0_0 ): __a : Optional[int] = 0 __a : Any = 1 for current_denominator in range(1 , limit + 1 ):...
577
0
"""simple docstring""" import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig,...
96
'''simple docstring''' __A : List[Any] = { 0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f', } def UpperCAmelCase ( lowerCamelCase_ :float ...
334
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __A ={} try: if not is_sentencepiece_available(): raise Optiona...
113
'''simple docstring''' import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput __A ='scheduler_config.json' class _snake_case ( a__ ): lowerCAmelCase ...
113
1
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.m...
361
"""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.ve...
361
1
'''simple docstring''' lowerCAmelCase_ : Union[str, Any] = tuple[float, float, float] lowerCAmelCase_ : List[Any] = tuple[float, float, float] def __a ( __lowerCamelCase : Pointad , __lowerCamelCase : Pointad ) -> Vectorad: '''simple docstring''' lowercas...
461
'''simple docstring''' def __a ( __lowerCamelCase : int = 200 ) -> int: '''simple docstring''' lowercase_ = [1, 2, 5, 10, 20, 50, 100, 200] lowercase_ = [0] * (pence + 1) lowercase_ = 1 # base case: 1 way to make 0 pence for coin in coins: ...
461
1
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as ProphetN...
64
"""simple docstring""" import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : ...
4
0
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCL...
21
"""simple docstring""" # Copyright (c) 2021-, NVIDIA CORPORATION. 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/...
21
1
'''simple docstring''' # 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 ..contr...
526
'''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/LICENS...
526
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.s...
707
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import Fla...
188
0
import math def UpperCamelCase ( ): '''simple docstring''' A_ : Optional[Any] = input('Enter message: ' ) A_ : List[Any] = int(input(f'''Enter key [2-{len(lowercase_ ) - 1}]: ''' ) ) A_ : Tuple = input('Encryption...
558
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : int = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { '''facebook/encodec_24khz''': '''https://huggingf...
72
0
"""simple docstring""" def lowerCamelCase_( ) -> list[list[int]]: '''simple docstring''' return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] _lowerCAmelCase : str = generate_large_matrix() _lowerCAmelCase : Union[str, ...
708
"""simple docstring""" 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 im...
386
0
"""simple docstring""" def A__ ( __lowerCamelCase ): """simple docstring""" return " ".join( ''.join(word[::-1] ) if len(__lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(r...
589
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : Any = { """configuration_informer""": [ """INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
589
1
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def lowerCAmelCase ( UpperCamelCase__ : Tuple="ro" , UpperCamelCase__ : Any="en" , UpperCamelCase__ : Dict="wmt16" , UpperCamelCase__ : Dict=None ): """si...
654
'''simple docstring''' import heapq import sys import numpy as np __lowerCAmelCase : Any = tuple[int, int] class A : def __init__( self : Optional[int] ) -> int: __UpperCAmelCase = [] __UpperCAmelCase ...
654
1
def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ ) -> list[list]: '''simple docstring''' UpperCAmelCase = current_set.copy() for row_index, row in enumerate(UpperCamelCase__ ): UpperCAmelCase = row[0] for column_index, column in enume...
130
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet impor...
130
1
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax...
338
'''simple docstring''' import sys import turtle def _lowerCAmelCase ( __snake_case : tuple[float, float] , __snake_case : tuple[float, float] ) -> tuple[float, float]: return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def _lower...
338
1
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/...
183
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( A__ ): """simple docstring""" lowercase__ = (IPNDMScheduler,) lowercase__ = (("""num_inference_steps""", 50),) d...
183
1
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWat...
378
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase_ : Tuple = logging.get_logger(__name__) lowerCAmelCase_ : List[str]...
378
1
'''simple docstring''' def __a ( _UpperCamelCase: str , _UpperCamelCase: str ) -> bool: """simple docstring""" _snake_case = len(_UpperCamelCase ) + 1 _snake_case = len(_UpperCamelCase ) + 1 # dp is a 2d matrix where dp[i][j] de...
185
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness UpperCamelCase_ : Dict = '''\ @misc{chen2021evaluating, ...
185
1
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase__ : list[int] = [o...
178
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor UpperCamelCase__ : List[str] = logging.get_logger(__name__) class _UpperCamelCase ( lowerCamelCase__ ): '''simple docstring''' def __init__...
178
1
'''simple docstring''' import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) lowercase_ : Any = logging.getLogger() def SCRE...
588
'''simple docstring''' import unittest import numpy as np from transformers import BertConfig, 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(): ...
588
1
from __future__ import annotations def lowerCAmelCase_ ( __UpperCAmelCase: list[int] , __UpperCAmelCase: int ) -> list[list[int]]: UpperCamelCase__ : list[list[int]] = [] UpperCamelCase__ : list[int] = [] UpperCamelCase_...
369
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models...
369
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): ...
345
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _UpperCAm...
362
0
'''simple docstring''' import string def _lowerCAmelCase( UpperCAmelCase_ : str ) -> str: lowerCAmelCase__ = """""" for i in sequence: lowerCAmelCase__ = ord(UpperCAmelCase_ ) if 65 <= extract <= 90: ...
211
'''simple docstring''' import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig _UpperCamelCase = { """faceboo...
211
1
"""simple docstring""" from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings...
674
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInpu...
674
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ : Any = { 'configuration_bigbird_pegasus': [ 'BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BigBi...
545
"""simple docstring""" from math import pi, sqrt, tan def lowercase_ ( _snake_case ): if side_length < 0: raise ValueError("""surface_area_cube() only accepts non-negative values""" ) return 6 * side_length**2 def lowercase_ ( _snake_case ,_snake_c...
545
1
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy...
602
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : Optional[Any] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kineti...
602
1
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature f...
295
"""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...
295
1
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
150
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _i...
569
0
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTest...
263
"""simple docstring""" import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttentio...
263
1
"""simple docstring""" class UpperCamelCase__ : """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE__ = "" , SCREAMING_SNAKE_CASE__ = False ) -> None: # Mapping from the first character of the prefix of the node A__ = ...
104
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegm...
509
0
class __lowerCAmelCase : def __init__( self ): '''simple docstring''' __lowerCamelCase = {} def lowerCamelCase ( self ): '''simple docstring''' print(self.vertex ) for i in self.vertex: print(__UpperCAmelCase , ''' -> '...
708
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __lowerCAmelCase ( lowerCAmelCase__ , unittest...
622
0
'''simple docstring''' import importlib.metadata import operator import re import sys from typing import Optional from packaging import version A = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>'...
125
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline A = logging.get_logger(__name__) # pylint: disable=invalid-name class __SCREAMING_SNAKE_C...
125
1
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _SCREAMING_SNAKE_CASE ( ) -> int: """simple docstring""" ...
713
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( A : list ) -> list: """simple docstring""" __snake_case : Tuple = False while is_sorted is False: # Until all the indices are traversed keep looping __snake_case : ...
61
0
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __magic_name__ (snake_case_ ): '''simple docstring''' __lowercase : str = (CMStochasticIterativeScheduler,) __lowercase :...
33
"""simple docstring""" from __future__ import annotations import requests def lowercase ( lowerCAmelCase__ : str ) -> dict: __a = f'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty''' return requests.get(lowerCAmelCase__ ).json() def...
695
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE ={ "configuration_roformer": ["ROFORMER_PRETR...
477
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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_par...
477
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, D...
622
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
1
'''simple docstring''' lowercase__ : List[Any] = 2_56 # Modulus to hash a string lowercase__ : Union[str, Any] = 1_00_00_03 def _lowerCAmelCase ( __snake_case : str , __snake_case : str ) -> bool: __A :...
718
'''simple docstring''' import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab fro...
338
0
"""simple docstring""" from sklearn.metrics import recall_score import datasets SCREAMING_SNAKE_CASE_ = "\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true...
373
"""simple docstring""" import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase__ : def __init__( self : Optional[Any] , _lowercase : int=2 , _lowercase : Option...
690
0
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_extraction_utils import FeatureExtrac...
710
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCamelCase ( __snake_case )...
546
0
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = OrderedDict( [ ...
6
from torch import nn def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: str ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f'''Unsupported activation function:...
6
1
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Bert...
76
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class UpperCAmelCase_ : '''simple docstring''' a__ = None def _lowercase ( self : Optional[int] ) -> str: ...
76
1
'''simple docstring''' import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput de...
78
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_image...
78
1
import re def lowerCAmelCase__ ( _a : str ): return [char.split() for char in re.split(R"[^ a-z A-Z 0-9 \s]" , str_ )] def lowerCAmelCase__ ( _a : str ): snake_case_ : List[str] = split_input(str_ ) return "".join( ["".join([cha...
114
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Any = logging.get_logger(__name__) lowercase : str = { '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json''', # See all Do...
114
1
'''simple docstring''' import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_...
98
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image...
702
import requests def a (_lowerCAmelCase , _lowerCAmelCase ): SCREAMING_SNAKE_CASE_ = {'''Content-Type''': '''application/json'''} SCREAMING_SNAKE_CASE_ = requests.post(_lowerCAmelCase , json={'''text''': message_body} , headers=_lowerCAmelCase ) i...
89
0
"""simple docstring""" import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unord...
163
"""simple docstring""" from __future__ import annotations def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ) -> tuple[str, float]: """simple docstring""" if (stress, tangential_force, area).count(0 ) != 1: ...
163
1
'''simple docstring''' import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class a__( lowerCAmelCase__ ): '''simple docstring''' UpperCAmelCase_ : List[str] = (EulerDiscreteSc...
605
'''simple docstring''' from math import ceil, sqrt def snake_case__ ( _A: int = 1000000 ) -> int: '''simple docstring''' lowerCAmelCase = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowerCAmelCase ...
605
1
from __future__ import annotations from math import pow, sqrt def lowerCamelCase__ ( _lowercase , _lowercase , _lowercase ): '''simple docstring''' if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) i...
30
import unittest import numpy as np def lowerCamelCase__ ( _lowercase , _lowercase , _lowercase , _lowercase = None , ): '''simple docstring''' UpperCAmelCase_ : Dict = np.shape(_lowercase ) UpperCAmelCase_ : Optional[Any] = np.shape(_lowerc...
30
1
'''simple docstring''' from collections.abc import Callable import numpy as np def UpperCamelCase_ ( A__ , A__ , A__ , A__ , A__ ): a_ = int(np.ceil((x_end - xa) / step_size ) ) a_ = np.zeros((n + 1,) ) a_ = ya a_ = xa for k in range(...
511
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( A__ , A__ , A__ , A__ ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): a_ , a_ = array[indexa], array[indexa] ...
511
1
from __future__ import annotations from cmath import sqrt def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_, snake_case_ ) -> List[str]: """simple docstring""" if a == 0: raise ValueError('''Coefficient \'a\' must not be zero.''' ) a = b * b - 4 * a...
387
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging UpperCAmelCase : Any ...
457
0
"""simple docstring""" from math import factorial __UpperCamelCase : dict[str, int] = {str(digit): factorial(digit) for digit in range(1_0)} def __UpperCAmelCase ( _snake_case : int ): if not isinstance(__UpperCamelCase, __UpperCamelCase ): raise TypeE...
711
"""simple docstring""" def __UpperCAmelCase ( _snake_case : int ): if num < 0: return False _lowercase = num _lowercase = 0 while num > 0: _lowercase = rev_num * 1_0 + (num % 1_0) num //= 1_0 return num_copy == rev_num if...
227
0
"""simple docstring""" from collections.abc import Sequence def lowercase_ ( _lowerCamelCase: Sequence[float] , _lowerCamelCase: bool = False ) -> float: '''simple docstring''' if not arr: return 0 __lowerCamelCase : int = 0 if allow_empty_sub...
646
"""simple docstring""" import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTe...
646
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelera...
718
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __snake_case ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE (...
15
0
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_...
30
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Dict = { 'configuration_distilbert': [ ...
365
0
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class A__ : """simple docstring""" __A : int __A : Node | None = None __A : ...
392
from collections import namedtuple lowercase : List[str] = namedtuple("""from_to""", """from_ to""") lowercase : Tuple = { """cubicmeter""": from_to(1, 1), """litre""": from_to(0.001, 1_0_0_0), """kilolitre""": from_to(1, 1), """gallon""": from_to(0.00_454, 264.172), ...
392
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logg...
324
from collections import deque def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : Union[str, Any] = len(_A ) __magic_name__ : Optional[int] = deque() __magic_name__ : Tuple = [False for _ in range(_A )] ...
324
1
"""simple docstring""" def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : List[Any] = [0 for i in range(len(_UpperCamelCase ) )] # initialize interval's left pointer and right pointer __lowerCAmelCase : List[str] = 0, 0 for i in range(1 , len(_UpperCamelCase ...
710
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils ...
549
0
"""simple docstring""" import sys def _UpperCamelCase ( A ): UpperCamelCase_ =len(A ) UpperCamelCase_ =[[0 for x in range(A )] for x in range(A )] UpperCamelCase_ =[[0 for x in range(A )] for x in range(A )] for chain_length in ra...
391
"""simple docstring""" import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark im...
391
1
from __future__ import annotations import os from collections.abc import Mapping snake_case_ = tuple[int, int] class _lowercase : def __init__( self , _UpperCAmelCase , _UpperCAmelCase ): A : set[int] = vertices A : dict[EdgeT, int...
700
'''simple docstring''' import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTenso...
537
0
from __future__ import annotations def a__ ( A__, A__ ): SCREAMING_SNAKE_CASE_ : Any = sorted(numsa + numsa ) SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ : Union[str, Any] = divmod(len(a__ ), 2 ) if mod == 1: return...
101
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch ...
420
0
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blanks.csv"""] ...
649
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase : int = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Funnel...
649
1
def _lowercase ( __UpperCamelCase : Any , __UpperCamelCase : Optional[int] , __UpperCamelCase : List[Any] , __UpperCamelCase : List[Any] ): if height >= 1: move_tower(height - 1 , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) ...
214
def _lowercase ( __UpperCamelCase : list ): snake_case__ = False while is_sorted is False: # Until all the indices are traversed keep looping snake_case__ = True for i in range(0 , len(__UpperCamelCase ) - 1 , 2 ): # iterating o...
214
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....
183
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_m...
183
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
9
'''simple docstring''' 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_m...
531
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCAmelCase ( __UpperCamelCase ): UpperCA...
188
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCase : Union[str, Any] = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/mai...
188
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Optional[int] = logging.get_logger(__name__) _A : Tuple = { """facebook/s2t-wav2vec2-large-en-de""": ( """https://huggingface.co/facebook/s2t-wav2v...
361
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def __magic_name__ ( __snake_case : float , __snake_case : float , __snake_case : float ) -> dict[str, float]: if (resistance, reactance, impedance).count...
361
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : str = logging.get_logger(__name__) UpperCAmelCase : Optional[int] = { "Salesforce/blip-vqa-base": "https://huggingface.c...
121
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device UpperCAmelCase : Dict = False class __SCREAMING_SNAKE_C...
121
1
'''simple docstring''' def __UpperCAmelCase ( lowerCamelCase_) -> Tuple: UpperCamelCase__ : Union[str, Any] = 1 UpperCamelCase__ : str = 2 while i * i <= n: UpperCamelCase__ : List[Any] = 0 while n % i ...
596
'''simple docstring''' from math import sqrt def __UpperCAmelCase ( lowerCamelCase_ = 1_000_000) -> int: UpperCamelCase__ : int = 0 UpperCamelCase__ : int = 0 UpperCamelCase__ : int while num_cuboids <= l...
596
1
from manim import * class lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE ): def __a ( self ): _lowercase : Any = Rectangle(height=0.5 , width=0.5 ) _lowercase : Optional[int] = Rectangle(height=0.46 , width=0.46 ).s...
703
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFM...
677
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Con...
80
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :int = 1_0**9 ) -> int: '''simple docstring''' lowercase = 1 lowercase = 2 lowercase = 0 lowercase = 0 lowercase ...
359
0
def snake_case_ ( SCREAMING_SNAKE_CASE_ ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence lowercase__ : Opti...
298
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.util...
298
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
693
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 a_ :Tuple = logging.get_logger(__name__) a_ :Optional[An...
35
0
"""simple docstring""" from typing import Any def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , ): _validation( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCame...
696
"""simple docstring""" import os def lowerCamelCase_ ( ): with open(os.path.dirname(_lowerCamelCase ) + '/p022_names.txt' ) as file: lowerCamelCase__ : Union[str, Any] = str(file.readlines()[0] ) lowerCamelCase__ : int = names.replace('"' , '' ...
696
1
from collections.abc import Sequence def __magic_name__ ( lowercase , lowercase ) -> float: """simple docstring""" return sum(c * (x**i) for i, c in enumerate(lowercase ) ) def __magic_name__ ( lowercase , lowercase ) ...
458
from string import ascii_uppercase UpperCAmelCase_ = {char: i for i, char in enumerate(ascii_uppercase)} UpperCAmelCase_ = dict(enumerate(ascii_uppercase)) def __magic_name__ ( lowercase , lowercase ) -> str: """simple docstring""" ...
458
1
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar UpperCAmelCase = TypeVar('''T''') UpperCAmelCase = TypeVar('''U''') class A_ ( Generic[T, U] ): '''simple docstring''' def __init__( self , snake_case , snake...
718
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = k_size // 2 lowercase ...
565
0
"""simple docstring""" import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_chann...
104
def __lowercase ( _UpperCamelCase ) ->list[int]: """simple docstring""" lowercase : Optional[Any] = len(_UpperCamelCase ) for i in range(_UpperCamelCase ): for j in range(i + 1, _UpperCamelCase ): if numbers[j] < numbers[i...
319
0
'''simple docstring''' import os import sys import unittest a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 ge...
347
'''simple docstring''' import sys from collections import defaultdict class a_ : def __init__( self : Union[str, Any] ) -> Optional[int]: snake_case: Any =[] def UpperCamelCase ( self : List[str] , a_ : ...
347
1
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = "T5Config" class __UpperCamelCase ( A__ ): ...
32
from __future__ import annotations def A__ ( SCREAMING_SNAKE_CASE_ : int ) -> bool: """simple docstring""" _UpperCAmelCase = str(SCREAMING_SNAKE_CASE_ ) return len(SCREAMING_SNAKE_CASE_ ) == 9 and set(SCREAMING_SNAKE_CASE_ ) == set('''12...
32
1
def lowerCAmelCase__ ( a__ ) ->Tuple: '''simple docstring''' _UpperCamelCase = 0 _UpperCamelCase = len(a__ ) for i in range(n - 1 ): for j in range(i + 1 , a__ ): if arr[i] > arr[j]: num_inversions += 1 return num_inversions def ...
703
import logging from transformers import PretrainedConfig lowerCamelCase__ = logging.getLogger(__name__) lowerCamelCase__ = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', } class _Upp...
82
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Dict = logging.get_logger(__name__) a_ : List[str] = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'studio-ousia/luke-large': ...
73
def __UpperCAmelCase ( lowerCamelCase_ : List[str] , lowerCamelCase_ : Optional[Any] ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE_ : List[Any] = [0 for i in range(r + 1 )] # nc0 = 1 SCREAMING_SNAKE_CASE_ : Dict = 1...
105
0
from __future__ import annotations def snake_case (__lowercase , __lowercase = None , __lowercase = None , __lowercase = False , ) -> tuple[int, float, str]: '''simple docstring''' _snake_case : Dict = cipher_alphabet or [chr(__lowercase ) for i in ran...
580
import math def snake_case (__lowercase , __lowercase ) -> float: '''simple docstring''' if ( not isinstance(__lowercase , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("power_factor must be a valid fl...
580
1
import math import random from typing import Any from .hill_climbing import SearchProblem def __lowercase ( lowerCamelCase : int , lowerCamelCase : bool = True , lowerCamelCase : float = math.inf , lowerCamelCase : float = -math.inf , lowerCamelCase : float = math.inf , ...
417
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __magic_name__ : List[Any] =logging.getLogger(__name__) class UpperCamelCase_ ( A ): """simple docst...
664
0
from math import factorial, radians def UpperCamelCase ( _A : float , _A : int = 18 , _A : int = 10 )-> float: """simple docstring""" A__ = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to r...
232
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distributed...
232
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __A ( A_ ...
560
"""simple docstring""" from ...processing_utils import ProcessorMixin class __A ( A_ ): '''simple docstring''' lowerCAmelCase : Tuple = "SpeechT5FeatureExtractor" lowerCAmelCase : Optional[Any] = "SpeechT5Toke...
560
1
import colorsys from PIL import Image # type: ignore def UpperCAmelCase__ ( lowerCamelCase_ : float , lowerCamelCase_ : float , lowerCamelCase_ : int ) -> List[str]: __a : List[Any] = x __a : Any = y for step in...
718
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer els...
577
0
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class __magic_name__ ( _lowerCAmelCase): _UpperCAmelCase : Opti...
333
'''simple docstring''' import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __snake_case (__UpperCAmelCase , __UpperCAmelCase=7 ): """simple docstring""" lowerCamelCase_ : List[Any] = None if tok...
501
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_available(): raise OptionalDependencyNotAvaila...
202
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, ResNetCo...
202
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Tuple = logging.get_logger(__name__) lowerCamelCase_ : Any = { """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config...
559
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 lowerCamelCase_ : Any = logging.getLogger(__name__) lowerCamelCase_ : ...
559
1
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _UpperCAmelCase ( __lowerCamelCase : int ) -> Tuple: # A local function to see if a dot lands in the circle. def is_in_circle(__lower...
716
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _UpperCAmelCase ( __lowerCamelCase : str ) -> None: _snake_case , _snake_case = analyze_text(__lowerCamelCase ) _snake_case ...
430
0
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel SCREAMING_SNAKE_CASE ...
94
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaT...
289
0
"""simple docstring""" import argparse lowercase = """docs/source/_static/js/custom.js""" def A__ ( _UpperCAmelCase : Any ) -> List[Any]: '''simple docstring''' with open(_UpperCAmelCase , encoding="utf-8" , newline="\n" ) as f: snake_case__ : Li...
700
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=_lowercase): '''simple docstring''' __magic_name__ : List[str] = ['''torch'''] def __init__( self , *lowerCamelCase__ , **...
150
0
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_in...
81
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar __lowerCAmelCase : Dict = TypeVar("KT") __lowerCAmelCase : Optional[Any] = TypeVar("VT") class a_ ( Generic[KT, VT] ): def __init__( s...
644
0
def a ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) UpperCamelCase : int = st...
643
import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class Up...
643
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, 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...
48
'''simple docstring''' import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="%(message)s") def A ( UpperCamelCase_ : np.ndarray ) -> np.ndarray: '''simple docstring''' return input_array.reshape((...
48
1
'''simple docstring''' def UpperCamelCase_ ( A__ ): a_ = len(A__ ) a_ = len(matrix[0] ) a_ = min(A__ , A__ ) for row in range(A__ ): # Check if diagonal element is not zero if matrix[row][row] != 0: # Eliminate all the elements below the diagonal for col in r...
713
'''simple docstring''' def UpperCamelCase_ ( A__ = 50 ): a_ = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): different_colour_ways_number[row_length][tile_length...
511
0
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class lowerCAmelCase__( unittest.TestCase ): '''simple docstring''' def UpperCamelCase_ ( self ) -> None: ...
249
import requests from bsa import BeautifulSoup def lowerCamelCase__ (__lowerCamelCase = "AAPL" ): _SCREAMING_SNAKE_CASE : Dict = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" _SCREAMING_SNAKE_CASE : str = BeautifulSoup(reque...
249
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available _lowerCAmelCase :List[str] = { """configuration_ernie""": ["""ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ErnieConfig...
179
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, 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...
179
1
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput...
58
"""simple docstring""" # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : str , __UpperCamelCase : Any ): '''simple docstring''' ...
58
1
'''simple docstring''' class __lowerCamelCase : """simple docstring""" def __init__( self : Optional[int] ) -> None: lowerCAmelCase__ = {} # Mapping from char to TrieNode lowerCAmelCase__ = False def a ( self : s...
710
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.uti...
125
0