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""" def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : int = 1000 ): lowerCAmelCase = -1 lowerCAmelCase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c lowerCAmelCase = (n * n - 2 * a * n) // (2 * n ...
4
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 SCREAMING_SNAKE_CASE__ : Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_...
205
0
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
531
from collections import namedtuple UpperCAmelCase = namedtuple("""from_to""", """from_ to""") UpperCAmelCase = { """cubicmeter""": from_to(1, 1), """litre""": from_to(0.001, 1000), """kilolitre""": from_to(1, 1), """gallon""": from_to(0.00_454, 264.172), """cubicyard""": from_to(0...
531
1
import sys import turtle def _snake_case (__lowercase , __lowercase): return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def _snake_case (__lowercase , __lowercase , __lowercase , __lowercase , ): my_pen.up() my_pen.goto(v...
23
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class a__: def __init__( self : List[Any] , __snake_case : str ): if isinstanc...
526
0
import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load_metric from .utils ...
110
from manim import * class UpperCamelCase ( snake_case__ ): """simple docstring""" def A( self : Dict ) -> Tuple: '''simple docstring''' A = Rectangle(height=0.5 ,width=0.5 ) A = Rectangle(height=0.46 ,width=0.46 ).set_stroke(wi...
110
1
"""simple docstring""" def _lowerCamelCase ( UpperCAmelCase__ ) -> bool: '''simple docstring''' if num < 0: return False a__ = num a__ = 0 while num > 0: a__ = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_num if __name__ =...
232
"""simple docstring""" __magic_name__ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def _lowerCamelCase ( ) -> None: '''simple docstring''' a__ = input('Enter message: ' ) a__ = input('Enter key [alphanumeric]: ' ) a__ = input('Encrypt/Decrypt [e/d]: ' ...
232
1
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_barthez impor...
702
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwr...
590
0
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) # pylint: disable=invalid-name class _A( snake_case__ ...
239
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : int = {'''configuration_ibert''': ['''IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''IBertConfig''', '''IBertOnnxConfig''']} try: if not is_torch_available(): ...
239
1
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_sa...
371
_UpperCAmelCase = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': 'ABBAA', 'o': 'ABBAB', 'p': 'ABBB...
371
1
"""simple docstring""" import datasets from .evaluate import evaluate __snake_case : Any = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy ...
293
import pytest import datasets # Import fixture modules as plugins __snake_case = ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def _A ( _lowercase , _lowercase ) -> Tuple: """simple docstring""" for item in ...
1
0
'''simple docstring''' import os from datetime import datetime as dt from github import Github UpperCAmelCase_ = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def ...
490
'''simple docstring''' 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 IterableDatase...
490
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class lowerCAmelCase__ ( unittest.TestCase , __magic_name__ ): '''simple docstring''' def __UpperCamelCase ( self ): '''simple d...
184
def __lowerCAmelCase ( A , A , A , A ): # Return True if there is node that has not iterated. UpperCAmelCase_ = [False] * len(A ) UpperCAmelCase_ = [] queue.append(A ) UpperCAmelCase_ = True while queue: UpperCAmelCase_ ...
162
0
'''simple docstring''' import datasets _lowerCAmelCase = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n ...
318
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( lowercase : List[str] , lower...
318
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowercase : List[Any] = { '''configuration_owlvit''': [ ...
36
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowerCAmelCase_ ( __magic_name__ ): __lowerCam...
18
0
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPIN...
459
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase : List[str] = logging.get_logger(__name__) __lowerCamelCase : str = { ...
459
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor import transformers ...
687
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCAmelCase_ (unittest.TestCase ): """simple docstring""" def SCREAMING_SNAKE_CASE__ ( self: int ): _lowerC...
687
1
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( __lowerCamelCase : str , __lowerCamelCase : str ): '''simple docstring''' _UpperCAmelCase : Union[str, Any] =get_failure_array(__lowerCamelCase ) # 2) St...
718
'''simple docstring''' import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, Ada...
331
0
from collections import Counter from timeit import timeit def _SCREAMING_SNAKE_CASE ( lowercase : str = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def _SCREAMING_S...
70
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : str = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_...
578
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_i...
76
# 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...
76
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 i...
543
"""simple docstring""" 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 a__ ( snake_case__ ) -> Dict[str, torch.Tensor]: lowerCamelCase = [] lowerCamelCase = [...
543
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging snake_case__ : List[str] = logging.get_logger...
171
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class SCREAMING_SNAKE_CASE_ (a__ ): ...
171
1
"""simple docstring""" import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.gener...
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 ...configuration_utils import PretrainedConfig from ...utils import logging a_ :Union[str, Any] = logging.get_logger(__name__) a_ :Dict = { 'facebook/xglm-564M': 'https://huggingface.co/facebook/xglm-564M/resolve/main/config.json', # See all XGLM models at https://huggingfac...
719
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequenceClas...
250
0
'''simple docstring''' from datetime import datetime import requests def UpperCamelCase_ ( A__ : str ): '''simple docstring''' lowerCAmelCase_ : str = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" lowerCA...
275
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
275
1
import math UpperCAmelCase__ : Any =10 UpperCAmelCase__ : Optional[Any] =7 UpperCAmelCase__ : List[str] =BALLS_PER_COLOUR * NUM_COLOURS def _lowercase ( _UpperCAmelCase = 20 ) -> str: lowerCamelCase =math.comb(_UpperCAmelCase , ...
269
def _lowercase ( _UpperCAmelCase , _UpperCAmelCase ) -> list[str]: return [sentence[i : i + ngram_size] for i in range(len(_UpperCAmelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
269
1
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Optional[Any] ) ...
17
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blenderb...
278
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass ...
712
import os # Precomputes a list of the 100 first triangular numbers SCREAMING_SNAKE_CASE__ = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def SCREAMING_SNAKE_CASE_ ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(__lowerCamelCase ) ) lo...
601
0
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_sche...
96
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def a_ ( ) -> Optional[Any]: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with ...
686
0
"""simple docstring""" def __UpperCAmelCase ( _snake_case : int ): _lowercase = [0] * len(_snake_case ) _lowercase = [] _lowercase = [] _lowercase = 0 for values in graph.values(): for i in values: indegree[i]...
227
"""simple docstring""" def __UpperCAmelCase ( _snake_case : list, _snake_case : list, _snake_case : int ): if len(_snake_case ) != len(_snake_case ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise Value...
227
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCamelCase = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M1...
96
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transforme...
96
1
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _a : '''simple docstring''' UpperCamelCase__ = 42 UpperCamelCase__ = None UpperCamelCase__ = No...
120
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig UpperCamelCase = { """susnato/ernie-m-base_pytorch""": """https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json""", """susnato/ernie-m-l...
120
1
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_tensor, load_image, load_numpy, slow,...
66
from PIL import Image def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Image: def brightness(SCREAMING_SNAKE_CASE ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError('level m...
66
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black 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 check_copies # noqa: E402 # This is the...
358
'''simple docstring''' from typing import Any class _a : def __init__( self : int , lowercase : Any ): '''simple docstring''' UpperCAmelCase = data UpperCAmelCase = None class _a : def __init__( se...
358
1
from manim import * class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' def _a ( self ): lowerCAmelCase_: List[str] = Rectangle(height=0.5 , width=0.5 ) lowerCAmelCase_: List[str] = Rectangle(height=0.4_6 , ...
613
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : List[str] = False class _lowercase ( unittest.TestCase ): ...
613
1
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _A : int =logging.get_logger(__name__) _A : Tuple ={ '''Intel/dpt-large''': '''https://huggingface.co/Intel...
631
'''simple docstring''' from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
631
1
__snake_case : int = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", """flax""": """flax>=0.4.1""", """hf-doc-build...
540
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, BertEncoder, ...
540
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCamelCase = {'configuration_encoder_decoder': ['EncoderDecoderCo...
363
"""simple docstring""" from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_m...
363
1
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline,...
31
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availab...
542
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_...
310
"""simple docstring""" import os def A_ ( ): '''simple docstring''' with open(os.path.dirname(_lowercase ) + """/grid.txt""" ) as f: snake_case_ :Optional[int] = [] # noqa: E741 for _ in range(20 ): l.append([int(_lowercase ...
310
1
"""simple docstring""" import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impo...
434
"""simple docstring""" from __future__ import annotations from cmath import sqrt def UpperCamelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) ->tuple[complex, complex]: if a == 0: raise ValueError('''Coefficient \'a\' must not be z...
434
1
"""simple docstring""" import doctest from collections import deque import numpy as np class a : def __init__( self : Dict ) -> None: lowerCamelCase_ = [2, 1, 2, -1] lowerCamelCase_ = [1, 2, 3, 4] def...
710
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : int , _lowerCamelCase : int ) -> int: while a != 0: lowerCamelCase_ , lowerCamelCase_ = b % a, a return b def lowerCamelCase__ ( _lowerCamelCase : int , _lo...
137
0
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 ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_mode...
550
import os from distutils.util import strtobool def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ): """simple docstring""" for e in env_keys: snake_case = int(os.environ.get(UpperCamelCase_ ,-1 ) ) if val >= 0...
550
1
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modelin...
472
def UpperCAmelCase_ ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = [] for data in source_data: for i, el in enumerate(_A ): if len(_A ) < i + 1: data_lists.append([] ) data_lists[i]...
472
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.ut...
553
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __SCREAMING_SNAKE_CASE = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'tokenization_tran...
553
1
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import loggin...
711
"""simple docstring""" import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ....
165
0
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_a...
109
'''simple docstring''' import os import sys _SCREAMING_SNAKE_CASE = os.path.join(os.path.dirname(__file__), "src") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequ...
366
0
import os def SCREAMING_SNAKE_CASE( ) -> str: with open(os.path.dirname(__UpperCamelCase ) + "/p022_names.txt" ) as file: a__ : Optional[Any] = str(file.readlines()[0] ) a__ : Optional[int] = names.replace("\"" , "" ).split("," ) names...
207
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import write_basi...
207
1
'''simple docstring''' import os from collections import deque import torch from torch.utils.data import Dataset class lowercase__ ( snake_case_ ): '''simple docstring''' def __init__( self , lowerCamelCase__="" , lowerCamelCase__="train" ): ...
212
'''simple docstring''' import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''', [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''', num_bytes=1337, num_examples=42, ...
212
1
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging A_ : Tuple = logging.get_logger(__name__) def UpperCAmelCase__ ( UpperCAmelCase__ :Dict ): '''simple d...
710
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ : Optional[int] = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', '''...
32
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : List[str] = logging.get_logger(__name__) __lowercase : Dict = { '''microsoft/cvt-13''': '''https://huggingface.co/microsoft/cvt-13/resolve/main/config.json''', ...
422
"""simple docstring""" import random def _lowerCamelCase ( lowerCamelCase__ : Tuple , lowerCamelCase__ : Dict , lowerCamelCase__ : str ): lowercase__ : List[Any] = a[left_index] lowercase__ : List[Any] = left_index + 1 for j in ...
200
0
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from transformers....
416
def _A ( _UpperCamelCase , _UpperCamelCase ): return number | (1 << position) def _A ( _UpperCamelCase , _UpperCamelCase ): return number & ~(1 << position) def _A ( _UpperCamelCase , _UpperCamelCase ): return number ^ (1 << position) def _A ( _UpperC...
416
1
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 lowercase__( UpperCAmelCase , uni...
97
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.tra...
482
0
"""simple docstring""" import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers i...
715
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attenti...
491
0
from manim import * class __snake_case ( SCREAMING_SNAKE_CASE ): def SCREAMING_SNAKE_CASE_ ( self ): """simple docstring""" lowerCAmelCase__ = Rectangle(height=0.5 ,width=0.5 ) lowerCAmelCase__ = Rectangle(height=0.46 ,width=0.46 ).set_str...
193
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( snake_case ): lowerCamelCase_ = (CMStochasticIterativeScheduler,) lowerCamelCase_ = 1_0 def _UpperCAmelCase ( ...
256
0
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata UpperCAmelCase_ = ...
718
from collections.abc import Iterable from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar('''_T''') class __SCREAMING_SNAKE_CASE ( Generic[_T] ): """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE__ = None ): """simple docstring""" ...
519
0
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 snake_case_ ( __UpperCamelCase ...
351
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import torch from...
351
1
from __future__ import annotations def __UpperCamelCase ( A ): if len(A ) < 2: raise ValueError('''Monogons and Digons are not polygons in the Euclidean space''' ) if any(i <= 0 for i in nums ): raise ValueError('''All values must be grea...
469
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging __magic_name__ =logging.get_logger(__name__) # pylint: disable=invalid-name class _A ( __UpperCamelCase ...
469
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"], "convert_funn...
59
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2StructConfig", "Pix2StructTextConfig", ...
59
1
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://hugg...
707
'''simple docstring''' from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available ...
44
0
'''simple docstring''' from collections import defaultdict from math import gcd def UpperCAmelCase__ ( UpperCAmelCase_ : int = 1_50_00_00 ) -> int: __lowerCamelCase : defaultdict = defaultdict(UpperCAmelCase_ ) __lowerCamelCase : Any ...
13
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping A__ : Optional[Any] = tuple[int, int] class UpperCAmelCase_ : """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ...
13
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer __lowerCAmelCase = logging.get_logger(__name__) __low...
709
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCAmelCase = get_tests_dir('''fixtures/spiece.mo...
335
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCamelCase_ : def __init__( self , lowerCamelCase_ ) -> Tuple: """simple docstring""" _UpperCamelCase = data _UpperCamelCase = [0x6745_2301, 0x...
147
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
698
0
'''simple docstring''' import math def __UpperCAmelCase ( a_: int ): _UpperCAmelCase : Union[str, Any] = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(a_ ) def __UpperCAmelCase ( a_: float ...
257
'''simple docstring''' import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() __a = ...
257
1
from collections.abc import Iterable from typing import Generic, TypeVar A_ : Union[str, Any] = TypeVar('_T') class A_ ( Generic[_T] ): '''simple docstring''' def __init__(self , lowercase__ = None ) -> Optional[int]: __UpperCAmelCase ...
303
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner im...
623
0
def lowercase ( __A : int ) -> bool: '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number or not...''') __lowercase :...
315
def lowercase ( __A : Dict ) -> Optional[Any]: '''simple docstring''' snake_case : Union[str, Any] = len(__A ) for i in range(length - 1 ): snake_case : Dict = i for k in range(i + 1 , __A ): if collection[k] <...
315
1
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, ...
235
# 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 # # Unl...
235
1
'''simple docstring''' import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class UpperCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ ): a...
714
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase ( lowerCamelCase : list ): '''simple docstring''' if not nums: raise ValueError("List is empty" ) return sum(lowerCamelCase ) / len(lowerCamelCase ) if __name__ == "__main__": im...
39
0
'''simple docstring''' import os from math import logaa def __magic_name__ ( __UpperCAmelCase = "base_exp.txt" ) -> int: '''simple docstring''' __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 for i, line in enumerate(open(os.path.join(os....
109
'''simple docstring''' from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) # TODO Update this a = { "facebook/esm-1b": "https://huggingface.co/facebook/esm-1b/re...
109
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Optional[Any] = logging.get_logger(__name__) _lowercase : Union[str, Any] = { "facebook/s2t-small-librispeech-asr": ( "https://huggingface.co/facebook/s2t-small...
30
'''simple docstring''' import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import ...
30
1
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _SCREAMING_SNAKE_CASE : List[str] = argparse.ArgumentParser( description=( '''Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned...
493
import unittest from knapsack import greedy_knapsack as kp class lowerCamelCase ( unittest.TestCase ): def A( self): __UpperCAmelCase : Optional[Any] = [1_0, 2_0, 3_0, 4_0, 5_0, 6_0] __UpperCAmelCase : str = [2, 4, 6, 8, 1_0, 1_2] __UpperCAmelCase ...
462
0
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMo...
700
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example snake_case__ : int = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0...
637
0
"""simple docstring""" from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFI...
480
"""simple docstring""" import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __lowercase ( _UpperCAmelCase): """simple docstring""" @require_torch ...
480
1
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging __snake_case : Optional[Any] = logging.get_lo...
705
'''simple docstring''' 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 ...tes...
687
0
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask lowerCamelCase_ = logging.getLogger(__name__) class a_ ( a_ ): '''simple docstring''' ...
318
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...
318
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : List[Any] = logging.get_logger(__name__) a__ : Union[str, Any] = { '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/confi...
719
def snake_case (UpperCamelCase : int ): '''simple docstring''' lowerCamelCase__ = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(2_7)) print(perfect_cube(4))
235
0
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/niels/...
201
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __lowerCAmelCase = 4 __lowerCAmelCase = 3 class lowerCamelCase ( __lowerCa...
201
1
def UpperCamelCase ( snake_case__): lowerCAmelCase_ : Dict = [int(snake_case__) for i in ip_va_address.split(".") if i.isdigit()] return len(snake_case__) == 4 and all(0 <= int(snake_case__) <= 2_54 for octet in octets) if __name__ == "__main__": _lowercase = input()...
683
class __snake_case : """simple docstring""" def __init__( self : Optional[int] ,lowerCAmelCase__ : str = "" ,lowerCAmelCase__ : bool = False ) -> None: '''simple docstring''' lowerCAmelCase_ : dict[str, RadixNode] = {} ...
683
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWit...
128
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version impor...
128
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/main/config.json', 'xlnet-large-cased': 'https://huggingface.co/xlnet-large-ca...
714
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @require_torch...
97
0
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def A ( snake_case__ , snake_case__=7 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = None if token ...
196
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig A_ : Union[str, Any] = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", ...
196
1
def _lowerCAmelCase( __A : float , __A : float , __A : int ): if principal <= 0: raise Exception("Principal borrowed must be > 0" ) if rate_per_annum < 0: raise Exception("Rate of interest must be >= 0" ) if years_to_repay <= 0 or not isinstance(lowerC...
708
lowerCAmelCase__ = { "a": "AAAAA", "b": "AAAAB", "c": "AAABA", "d": "AAABB", "e": "AABAA", "f": "AABAB", "g": "AABBA", "h": "AABBB", "i": "ABAAA", "j": "BBBAA", "k": "ABAAB", "l": "ABABA", "m": "ABABB", "n": "ABBAA", "o": "ABBAB", "p": "ABBBA", ...
1
0
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, b...
483
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.c...
262
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.uti...
366
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class _snake_case : snake_case__ = None snake_case__ = False snake_case__ = False snake_case__ = False snake_c...
366
1
'''simple docstring''' from __future__ import annotations def UpperCamelCase ( _lowerCamelCase : Optional[int] , _lowerCamelCase : Any ): # Checks if the entire collection has been sorted if len(_lowerCamelCase ) <= 1 or n <= 1: return insert_next(_lowerCamelCa...
440
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__:Optional[Any] = {"""configuration_reformer""": ["""REFORMER_PR...
528
0
'''simple docstring''' 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 ....
718
'''simple docstring''' 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, ...
270
0
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class _a ( SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self, *A, **A ): '''simple doc...
28
'''simple docstring''' import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging UpperCam...
28
1
class _UpperCamelCase : '''simple docstring''' def __init__( self : List[str] , snake_case_ : int , snake_case_ : Optional[Any]=None , snake_case_ : List[str]=None ): UpperCamelCase_: List[Any] = data UpperCamelCase_: ...
670
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def lowerCAmelCase__ ( self : Optional[int] ): Up...
670
1
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_w...
58
"""simple docstring""" import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def lowercase (*SCREAMING_SNAKE_CASE_ : Optional[Any] , SCREAMING_SNAKE_CASE_ : Optional[Union[Dict, Any]] = None , ...
247
0
import unittest from knapsack import knapsack as k class __snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE_ ( self ): """simple docstring""" lowerCAmelCase__ = 0 lowerCAmelCase__ = [0] lowerCAmelCase__ = [0] lowerC...
703
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def UpperCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ = "x" , snake_case__ = 10**-10 , snake_case__ = 1 , ) -> complex: """simple docstring""" lowerCAmelCase...
604
0
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> Any: SCR...
100
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch cl...
455
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device ...
391
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate __magic_name__ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("", "|", "|"), ...
391
1
'''simple docstring''' import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' def _lowerCAmelCase( ...
152
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decoder, D...
152
1
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(): from ..models.auto.modeling_...
718
from __future__ import annotations def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) ->dict[str, float]: if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: raise ValueError("Resistance c...
592
0
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _a ( unittest.TestCase ): def __snake_case (self ) -> List[Any]: UpperCAmelCase_: Optional[int] = [ """safety_checker/pyto...
556
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
556
1
"""simple docstring""" 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 AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def SCREAMING_SNAKE_CASE__ ...
709
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING a_ = logging.get_logger(__name__) class __lowercase ( _UpperCAmelCase): """simple docstring""" ...
48
0
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''facebook/encodec_24khz''': '''https://...
426
import unittest from knapsack import greedy_knapsack as kp class _A ( unittest.TestCase ): def __a ( self : List[Any] ) -> Optional[int]: """simple docstring""" lowercase : Dict = [10, 20, 30, 40, ...
217
0
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( a : int ) ->list[int]: snake_case = [True] * limit snake_case = False snake_case = False snake_case = True for i in range(3 , int(limit**0.5 + 1 ) , 2 ...
711
'''simple docstring''' from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() exc...
44
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_t...
6
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowerCamelCase = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
6
1
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCAmelCase_ ( lowercase_ ): SCREAMING_SNAKE_CASE_ : Tuple...
709
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor UpperCAmelCase__ : Dict = logging.get_logger(__name__) class lowerCAmelCase_ ( lowercase_ ): def __init__( self : List[Any] , *UpperCAmelCase_ ...
416
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( UpperCamelCase__ ): _lowercase : str = ['''image_processor''', '''tokenizer'''] _lowercase : Any = '''CLIPImagePro...
43
from __future__ import annotations def lowerCamelCase__ ( __A :list[float] ,__A :Union[str, Any] ): """simple docstring""" print(F'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(__A ): print(F'{i}\t\t{d}' ) ...
268
0
import math import unittest def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> bool: assert isinstance(__lowerCAmelCase , __lowerCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True ...
713
from string import ascii_lowercase, ascii_uppercase def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> str: if not sentence: return "" snake_case__ = dict(zip(__lowerCAmelCase , __lowerCAmelCase ) ) return lower_to_upper.get(sentence[0]...
208
0