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 argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ (_SCREAMING_SNAKE_CASE :Optional[int] , _SCREAM...
473
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test...
473
1
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transfor...
175
import csv import tweepy # Twitter API credentials a = "" a = "" a = "" a = "" def _SCREAMING_SNAKE_CASE ( snake_case ) -> None: # authorize twitter, initialize tweepy _UpperCAmelCase = t...
175
1
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : List[Any]=False ): """simple docstring""" ...
480
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __A ( unittest.TestCase ): def A__ ( self :Tuple ): '''simple docstring''' debug_launcher(test_s...
21
0
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 if is_flax_available(): from ...
700
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class __lowercase ( a__ ): def __init__( self : List[Any] , *lowercase__ : ...
143
0
'''simple docstring''' 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 ...
128
'''simple docstring''' from math import factorial def lowerCAmelCase__ ( lowerCamelCase : int ,lowerCamelCase : int ,lowerCamelCase : float ): if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or ...
128
1
"""simple docstring""" def a_ ( lowerCamelCase ): if not isinstance(lowerCamelCase , lowerCamelCase ) or number < 0: raise ValueError('Input must be a non-negative integer' ) UpperCAmelCase__ = 0 while number: # This way we arrive at next set bit (next 1) ...
632
"""simple docstring""" lowerCAmelCase__ : Tuple = range(2, 20 + 1) lowerCAmelCase__ : Optional[Any] = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : dict[int, dict[int, list[list[int]]]] = {} def a_ ( lowerCamelCase , lowerCamelCase ,...
632
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import log...
441
# Function to print upper half of diamond (pyramid) def __snake_case ( __magic_name__ ): '''simple docstring''' for i in range(0 , __magic_name__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(" " , end="" ) ...
441
1
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available()...
716
import os def UpperCamelCase ( ): '''simple docstring''' __snake_case :List[str] = os.path.dirname(os.path.realpath(snake_case__ ) ) __snake_case :Union[str, Any] = os.path.join(snake_case__ ,"""triangle.txt""" ...
291
0
"""simple docstring""" import math import unittest from transformers import BioGptConfig, 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_...
77
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ) -> Tuple: '''simple docstring''' import os as original_os from os import path as original_path from os impor...
371
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) UpperCAmelCase__ = { 'configuration_speech_to...
430
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) UpperCAmelCase__ = pytest.mark.integration @pytest.mark.pa...
430
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Tuple = logging.get_logger(__name__) snake_case : Dict = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config....
545
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 .tokeni...
387
0
'''simple docstring''' from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from ...
710
'''simple docstring''' # Lint as: python3 import itertools import os import re __snake_case = re.compile(r"""([A-Z]+)([A-Z][a-z])""") __snake_case = re.compile(r"""([a-z\d])([A-Z])""") __snake_case = re.compile(r"""(?<!_)_(?!_)""") __snake_case = re.compile(r"""(_{2,})""") __snake_case ...
603
0
"""simple docstring""" import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MOD...
46
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ...
46
1
'''simple docstring''' import math def lowercase_ ( lowercase__ , lowercase__ ) ->float: return math.pow(lowercase__ , 2 ) - a def lowercase_ ( lowercase__ ) ->float: return 2 * x def lowercase_ ( lowercase__ ) ...
273
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping A : Optional[Any] = tuple[int, int] class lowerCamelCase : def __init__( self : Tuple , __snake_case : set[int] , __snake_case : Mapping[E...
273
1
import os def a_ ( __lowercase : str = "matrix.txt" ) -> int: with open(os.path.join(os.path.dirname(__lowercase ) , __lowercase ) ) as in_file: _snake_case = in_file.read() _snake_case = [[int(__lowercase ) for cell in row...
686
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPool...
686
1
"""simple docstring""" import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant...
714
"""simple docstring""" 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 ImageProcessingSavingTestMix...
173
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCamelCase ) class lowerCamelCase_ ( lowerCamelCase ): a__ = field(default='''audio-classi...
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast ...
67
0
def lowerCAmelCase_ ( snake_case_ = 1,snake_case_ = 1000 ): _A : Optional[int] = 1 _A : List[Any] = 0 for divide_by_number in range(snake_case_,digit + 1 ): _A : list[int] = [] _A : Any = numerator for _ ...
707
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(): import...
54
0
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :Optional[int] , SCREAMING_SNAKE_CASE :List[str] , SCREAMING_SN...
504
"""simple docstring""" import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTester...
196
0
def a_ ( __magic_name__ ) -> List[Any]: """simple docstring""" if not head: return True # split the list to two parts snake_case : str = head.next, head while fast and fast.next: snake_case : U...
721
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler...
84
0
import numpy as np __a: List[str] = [ ['''a''', '''b''', '''c''', '''d''', '''e'''], ['''f''', '''g''', '''h''', '''i''', '''k'''], ['''l''', '''m''', '''n''', '''o''', '''p'''], ['''q''', '''r''', '''s''', '''t''', '''u'''], ['''v''', '''w''', '''x''', '''y''', '''z'''], ] cl...
108
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization...
108
1
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import Tokenizer...
720
"""simple docstring""" class lowerCAmelCase_ ( lowerCAmelCase ): """simple docstring""" pass class lowerCAmelCase_ ( lowerCAmelCase ): """simple docstring""" pass class lowerCAmelCase_ : """simple docstring""" def __init...
104
0
"""simple docstring""" import math def a ( __UpperCAmelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all...
96
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : """simple docstring""" __a =42 __a =42 class __SCREAMING_SN...
692
0
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulator, create_optimizer @requ...
626
from __future__ import annotations from collections.abc import Iterator from typing import Any class a__ : """simple docstring""" def __init__( self , lowercase ) -> int: '''simple docstring''' A__ = data A__ = None class ...
626
1
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __UpperCAmelCase ( __a ): def __init__( self , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): ...
274
'''simple docstring''' from __future__ import annotations from typing import Any def snake_case_ ( __snake_case : list[Any]) -> None: create_state_space_tree(__snake_case , [] , 0) def snake_case_ ( __snake_case : list[Any] , __snake_case : list...
274
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
715
# 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 require...
641
0
import itertools import string from collections.abc import Generator, Iterable def UpperCamelCase ( lowercase_ , lowercase_ ) -> Generator[tuple[str, ...], None, None]: '''simple docstring''' lowercase__ : Any = iter(lowercase_ ) while True: lowercase__ : ...
12
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats...
49
0
lowerCAmelCase_ : List[Any] = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' lowerCAmelCase_ : Optional[int] = [{'type': 'co...
701
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowerCAmelCase_ : Any = argparse.ArgumentParser( description=( 'Extraction some layers of the fu...
464
0
'''simple docstring''' __lowerCamelCase = '''Tobias Carryer''' from time import time class A__ : def __init__( self , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__=int(time() ) ) -> Optional[int]: # noqa: B00...
288
'''simple docstring''' from math import pow def UpperCAmelCase__ ( UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, UpperCAmelCase__, ) -> tuple[int, int]: if current_sum == needed_sum: # If the sum of the powers is eq...
288
1
def _snake_case ( SCREAMING_SNAKE_CASE ) -> Dict: """simple docstring""" _lowerCAmelCase : Any = 0 _lowerCAmelCase : Union[str, Any] = len(SCREAMING_SNAKE_CASE ) for i in range(n - 1 ): for j in range(i + 1 , SCREAM...
503
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def _snake_case ( SCREAMING_SNAKE_CASE ) -> Dict[str, torch.Tensor]: """simple docstring""" _lowerCAmelCase : int ...
503
1
'''simple docstring''' 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,...
330
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, Timeste...
8
0
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( "The conv...
707
"""simple docstring""" def snake_case ( _a: List[Any] , _a: Any , _a: str , _a: List[Any] )-> List[Any]: '''simple docstring''' lowerCamelCase__ = [False] * len(_a ) lowerCamelCase__ = [] queue.append(_a ...
659
0
'''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 accele...
44
import collections import importlib.util import os import re from pathlib import Path lowercase_ = """src/transformers""" # Matches is_xxx_available() lowercase_ = re.compile(R"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowercase_ ...
235
0
'''simple docstring''' def _UpperCamelCase ( __A , __A ) -> Union[str, Any]: '''simple docstring''' UpperCamelCase__ = len(__A ) UpperCamelCase__ = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr...
706
'''simple docstring''' def _UpperCamelCase ( __A ) -> float: '''simple docstring''' if edge <= 0 or not isinstance(__A , __A ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def _...
223
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : Tuple = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransfo...
23
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { """configuration_upernet""": ["""UperNetConfig"""], } try: if not is_torch_available(): raise OptionalD...
111
0
'''simple docstring''' import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common ...
700
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
77
0
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): impo...
75
'''simple docstring''' def __UpperCamelCase ( a : int = 50 ) ->int: snake_case = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_len...
342
0
'''simple docstring''' def A__ ( __lowerCAmelCase : int = 400_0000 ): lowerCamelCase__ = [0, 1] lowerCamelCase__ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break ...
9
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : Tuple = logging.get_logger(__name__) UpperCamelCase : List[str] = { 'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resol...
9
1
from math import factorial def SCREAMING_SNAKE_CASE_ ( snake_case__ , snake_case__ ) -> int: # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise Valu...
312
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers...
360
0
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib ...
12
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __a (UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Tuple = (DDPMScheduler,) def _a ( self , **_a ) -> ...
12
1
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_bar, enable_p...
85
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable SCREAMING_SNAKE_CASE__ : Any = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]...
85
1
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCAmelCase: Optional[int] = TypeVar('KEY') lowerCAmelCase: Tuple = TypeVar('VAL') @dataclass(frozen=lowerCamelCase__ , slots=lowerCamelCase...
195
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers i...
195
1
import math class UpperCAmelCase : '''simple docstring''' def lowerCAmelCase_ ( self , lowercase , lowercase ): """simple docstring""" A_ : Optional[Any] = 0.0 A_ : Dict = 0.0 fo...
558
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_c...
558
1
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 __lowerCamelCase : str = '''\ @misc{chen2021evaluating, title={Evaluat...
379
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features ...
379
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase__ : str = { """configuration_altclip""": [ """ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AltCLIPConfig""", ...
12
# 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...
12
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor lowercase_ : Dict = logging.get_logger(__name__) class __UpperCamelCase (_UpperCAmelCase ): def __init__( self , *_lowerCAmelCase , **_lo...
653
'''simple docstring''' import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visio...
653
1
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 if is_flax_available(): ...
63
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixi...
63
1
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class A_ ( datasets.BuilderConfig ): _lowerCamelCase : Optional[data...
717
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class A_ ( unittes...
119
0
'''simple docstring''' from sklearn.metrics import fa_score import datasets UpperCAmelCase_ : Dict = ''' 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) ''' UpperCAmelCase_ : Union[st...
24
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSeque...
324
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class __lowercase (Uppe...
712
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCamelCase = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "tokenization_gpt_neox_j...
583
0
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia ...
526
from __future__ import annotations def lowerCAmelCase__(__snake_case ,__snake_case ) -> list[int]: '''simple docstring''' lowerCamelCase__ = 0 lowerCamelCase__ = len(__snake_case ) - 1 while i < j: if nums[i] + nums[j] == target: retur...
481
0
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel UpperCamelCase = { '''g...
717
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
677
0
from __future__ import annotations class a : """simple docstring""" def __init__( self , lowerCAmelCase_ ) -> Any: _A = TypeError( """Matrices must be formed from a list of zero or more lists containing at """ ""...
401
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization...
108
0
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class snake_case__ ( __lowerCAmelCase ): """simple docstring""" ...
717
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case__ ( lowerCAmelCase_ ): """simple docstring""" _SCREAMING_SNAKE_CASE = ["""image_processor""", """tokenizer"""] _SCREAMING_SNAKE_CASE ...
243
0
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def lowercase__ ( lowercase_ ,lowercase_ ,lowercase_ ,lowercase_ = 100 ,) -> float: """simple docstring""" _UpperCamelCase : Any = x_start ...
624
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGenerat...
624
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING __A : Tuple = logging.get_logger(__name__) __A : List[str] =...
75
from collections import deque from math import floor from random import random from time import time class _SCREAMING_SNAKE_CASE : def __init__( self )-> List[str]: lowerCamelCase_ ={} def _snake_case ( self , _SCREAMING_SNAKE_CASE , _SC...
75
1
import argparse import os import platform import numpy as np import psutil import torch from accelerate import __version__ as version from accelerate.commands.config import default_config_file, load_config_from_file from ..utils import is_npu_available, is_xpu_available def lowercase_ ( _UpperCamelCase=None ...
639
"""simple docstring""" import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokeni...
96
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tens...
719
from functools import reduce UpperCamelCase = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """66...
152
0
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __A = get_tests_dir("fixtures/test_sentencepiece_with_bytefallback.model") @requir...
68
'''simple docstring''' import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( snake_case_ ): """simple docstring""" A__ : Union[str, Any] = (DDIMParallelScheduler,) A__ : Opt...
135
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import...
49
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_...
49
1
'''simple docstring''' from manim import * class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' def a ( self : Tuple ) -> Optional[Any]: __lowerCAmelCase = Rectangle(height=0.5 , width=0.5 ) __lowerCAmelCase ...
427
'''simple docstring''' def UpperCamelCase_ ( snake_case_ : str ) -> str: '''simple docstring''' return "".join(chr(ord(snake_case_ ) - 32 ) if """a""" <= char <= """z""" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
427
1
'''simple docstring''' import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_availab...
717
'''simple docstring''' # limitations under the License. # 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 .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils...
640
0
def a__ ( A__ ): if not isinstance(A__, A__ ): raise ValueError('multiplicative_persistence() only accepts integral values' ) if num < 0: raise ValueError('multiplicative_persistence() does not accept negative values' ) SCREAMING_SNAKE_CASE_ : str ...
101
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available ...
101
1
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : '''simple docstring''' _a = 42 _a = 42 class __S...
625
"""simple docstring""" _lowercase : Optional[Any] = { "Pillow": "Pillow<10.0.0", "accelerate": "accelerate>=0.20.3", "av": "av==9.2.0", "beautifulsoup4": "beautifulsoup4", "black": "black~=23.1", "codecarbon": "codecarbon==1.2.0", "cookiecutter": "cookiecutter==1.7.3", ...
625
1
"""simple docstring""" import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVec...
49
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowercase ( unittest.TestCase ): def a ( self ): snake_case_ = 10 def a ...
362
0
"""simple docstring""" from manim import * class snake_case_ ( _lowerCamelCase ): """simple docstring""" def _UpperCAmelCase ( self ): """simple docstring""" A__ = Rectangle(height=0.5 , width...
554
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', ...
554
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _SCREAMING_SNAKE_CASE = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxCo...
502
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PN...
502
1
'''simple docstring''' class A : '''simple docstring''' def __init__(self ) -> Optional[Any]: __UpperCamelCase : int = 0 __UpperCamelCase : Any = 0 __UpperCamelCase : Union[str, Any] = {...
710
'''simple docstring''' import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTeste...
399
0
"""simple docstring""" def snake_case__ ( _lowerCamelCase = 1_00_00_00 ) ->int: """simple docstring""" __lowercase : int = 1 __lowercase : Optional[Any] = 1 __lowercase : Optional[Any] = {1: 1} for inputa in range(2,...
575
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __A : List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNo...
575
1
import os def UpperCamelCase ( ): '''simple docstring''' with open(os.path.dirname(lowerCAmelCase__ ) + '''/p022_names.txt''' ) as file: lowercase = str(file.readlines()[0] ) lowercase = names.replace('''"''' , '''''' ).split(''',''' ) names.sort() ...
720
import os def UpperCamelCase ( lowerCAmelCase__ = "input.txt" ): '''simple docstring''' with open(os.path.join(os.path.dirname(lowerCAmelCase__ ) , lowerCAmelCase__ ) ) as input_file: lowercase = [ [int(lowerCAmelCase__ ) for element in line.split(''',''' )] ...
633
0
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance A_ = 6378137.0 A_ = 6356752.314245 A_ = 6_3_7_8_1_3_7 def UpperCAmelCase ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase )-> float: ...
393
def UpperCAmelCase ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase )-> list: '''simple docstring''' SCREAMING_SNAKE_CASE_ = len(UpperCAmelCase ) SCREAMING_SNAKE_CASE_ = [[0] * n for i in range(UpperCAmelCase )] for i in range(UpperCAm...
393
1
'''simple docstring''' from math import sqrt def SCREAMING_SNAKE_CASE( UpperCamelCase = 1_0_0_0_0_0_0 ) -> int: UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int = 0 UpperCAmelCase_ : int while num_cuboids <= limit: max_cuboid_size...
471
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", ...
471
1
'''simple docstring''' import math import unittest def __UpperCAmelCase ( SCREAMING_SNAKE_CASE__: int ) -> bool: """simple docstring""" assert isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ) and ( number >= 0 ), "'number' m...
448
'''simple docstring''' import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : int = logging.get_logger(__name__) __UpperCamelCase ...
448
1
def a ( snake_case__: str ): '''simple docstring''' lowercase_ = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) lowercase_ = hex_num[0] == '''-''' if is_negative: lowerca...
409
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowercase__( unittest.TestCase ): """simple docstring""" def _lowercase ( self : Dict ) -> int: lowercase_ = [ '''safety_checker/pytorch_mode...
409
1
'''simple docstring''' from __future__ import annotations lowercase = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '...
211
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class __lowerCamelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' @staticmethod @abstractmethod def a_ ( a__ ): raise NotImpleme...
211
1
'''simple docstring''' import math def snake_case_ ( _lowerCAmelCase : Optional[int] ) -> int: if not isinstance(_lowercase , _lowercase ): UpperCAmelCase : Any = f"""Input value of [number={number}] must be an integer...
704
'''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 @r...
528
0
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets _lowerCAmelCase :Tuple = datasets.logging.get_logger(__name__) _lowerCAmelCase :List[str] = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and ...
506
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class _UpperCAmelCase ( a ): '''simple do...
506
1
import flax.linen as nn import jax import jax.numpy as jnp class a_ ( nn.Module ): UpperCamelCase__ : int UpperCamelCase__ : jnp.dtype =jnp.floataa def __a ( self :Dict) -> List[str]: UpperCAmelCase_ = nn.Conv( ...
712
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def A ( ) -> Optional[int]: '''simple docstring''' raise RuntimeError('''CUDA out of memory.''' ) ...
561
0
"""simple docstring""" def lowercase__ ( snake_case_ :int , snake_case_ :int ): while second != 0: __UpperCAmelCase = first & second first ^= second __UpperCAmelCase = c << 1 return first if __name__ == "__main__": import doctest doctes...
49
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __UpperCAmelCase = TypeVar('''KEY''') __UpperCAmelCase = TypeVar('''VAL''') @dataclass(frozen=a__ , ...
90
0
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_be...
701
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
281
0
from __future__ import annotations from collections import Counter from random import random class _snake_case : def __init__( self): '''simple docstring''' lowercase__ : List[Any] = {} def lowercase__ ( self , SCREAMING_SNAKE_CASE_): ...
12
'''simple docstring''' from collections import namedtuple snake_case : Optional[int] = namedtuple('from_to', 'from_ to') snake_case : Any = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.001, 1_000), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_0454, 264.172), 'cubicy...
566
0
from math import ceil def _UpperCamelCase ( UpperCamelCase_ : int = 1001 ) -> int: """simple docstring""" lowerCAmelCase__ = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): lowerCAmelCase__ = 2 * i + 1 ...
365
from collections import deque from .hash_table import HashTable class __SCREAMING_SNAKE_CASE ( __lowercase): def __init__( self , *_UpperCamelCase , **_UpperCamelCase ): """simple docstring""" super().__init__(*_UpperCamelCase , ...
365
1
"""simple docstring""" import os from distutils.util import strtobool def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> List[str]: '''simple docstring''' for e in env_keys: _lowerCamelCase : List[Any] = int(os.environ.get(_lowerCamelCase ...
46
'''simple docstring''' 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, ...
126
0
def a_ ( __snake_case , __snake_case ) -> Dict: '''simple docstring''' UpperCamelCase_ = 0 UpperCamelCase_ = len(__snake_case ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == so...
559
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __a : Union[str, Any] = logging.get_logger(__name__) def a_ ( __snake_case ) -> str: '''...
559
1
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class A ( yaml.SafeLoader ): '''simple docstring''' def lowerCamelCase__ (self : Tuple , _UpperCAmelCase : Optional[int] ) -> Union[...
15
# Function to print upper half of diamond (pyramid) def __snake_case ( __magic_name__ ): '''simple docstring''' for i in range(0 , __magic_name__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(" " , end="" ) ...
441
0
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): ...
705
def A ( UpperCAmelCase ): if n == 1 or not isinstance(UpperCAmelCase , UpperCAmelCase ): return 0 elif n == 2: return 1 else: _snake_case : List[Any] = [0, 1] for i in range(2 , n + 1 ): ...
278
0
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _lowerCAmelCase( UpperCAmelCase_ ): """simple docstring""" a : Optional[An...
57
"""simple docstring""" 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 Token...
610
0
'''simple docstring''' # Imports import numpy as np class _lowerCAmelCase : def __init__( self : List[Any] , __snake_case : List[Any]=None , __snake_case : Optional[int]=None , __snake_case : Optional[Any]=None , __snake_case : ...
704
def _lowerCamelCase ( a_ : list): if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''') for cell_n in range(1 , len(grid[0])): grid[0][cell_n] += grid[0][cell_n - 1] lowerCamelCase :Any = grid[0] for ...
49
0
from __future__ import annotations from math import pi, sqrt def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> tuple: if inductance <= 0: raise ValueError('Inductance cannot be 0 or negative' ) elif capacitance <= 0: ...
66
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): ...
66
1
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO, ) _UpperCAmelCase = logging....
70
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], """tokenization_biogpt""": ["""BioGptT...
70
1
def UpperCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase ) -> float: return price * (1 + tax_rate) if __name__ == "__main__": print(F'{price_plus_tax(100, 0.25) = }') print(F'{price_plus_tax(125.50, 0.05) = }')
509
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency __lowerCAmelCase : Dict = { "E": 12.70, "T": 9.06, "A": 8.17, "O": 7.51, "I": 6.97, "N": 6.75, "S": 6.33, "H": 6.09, "R": 5.99, "D": 4.25, "L": 4.03, ...
509
1
def UpperCamelCase_ ( a_ ) ->int: A =1 for i in range(1 , num + 1 ): fact *= i return fact def UpperCamelCase_ ( a_ ) ->int: A =0 while number > 0: A =number % 10 sum_of_digits += last_digit A =number // 10 # Removing the last_digit from the give...
689
def UpperCamelCase_ ( a_ , a_ , a_ ) ->int: def count_of_possible_combinations(a_ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) return count_of_possible_combinati...
689
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : List[Any] = logging.get_logger(__name__) __a : List[Any] = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/c...
534
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logging ...
534
1
import os def a__ ( ): '''simple docstring''' __magic_name__ = os.path.join(os.path.dirname(A_ ), """num.txt""" ) with open(A_ ) as file_hand: return str(sum(int(A_ ) for line in file_hand ) )[:10] if __name__ == "__main__": p...
710
import math import random def a__ ( A_, A_ = False ): '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value __lowerCAmelCase : Union[str, Any] = 0.02 def a__ ( A_, A_ ): ...
76
0
from collections import defaultdict class lowerCAmelCase_ : def __init__( self , _lowerCAmelCase , _lowerCAmelCase ): _lowercase : Optional[Any] = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N # initiall...
66
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json""", # See all GPTNe...
420
0
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase ( __snake_case ): '''simple docstring''' lowerCAmelCase__ = ['''image_processor''', '''tokenizer'''] lowerCAmelCase__...
701
'''simple docstring''' import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import...
43
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMod...
47
'''simple docstring''' def UpperCamelCase ( ) -> int: '''simple docstring''' return 1 def UpperCamelCase ( lowercase_ : int ) -> int: '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def UpperCamelCase ( lowercase_ : ...
72
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta....
710
"""simple docstring""" import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_ba...
615
0
'''simple docstring''' import argparse import os import platform import numpy as np import psutil import torch from accelerate import __version__ as version from accelerate.commands.config import default_config_file, load_config_from_file from ..utils import is_npu_available, is_xpu_available def __SCRE...
620
'''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.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipel...
135
0
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def lowerCamelCase__ ( a ): for param in module.parameters(): __snake_case = False def lowerCamelCase__ ( ): __snake_case = 'cuda' if torch.cuda...
427
'''simple docstring''' import argparse import copy def lowerCamelCase__ ( a ): __snake_case = {} with open(a ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __snake_case = [] ...
427
1