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
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common impor...
167
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Union[str, Any] = { 'configuration_git': ['GIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GitConfig', 'GitVisionConfig'], 'processing_...
3
0
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def a__ ( a = "isbn/0140328726" ) -> dict: A_ : Optional[Any] = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if new_olid.count...
721
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 UpperCAmelCase ( self ): """simple docs...
236
0
'''simple docstring''' # using dfs for finding eulerian path traversal def _SCREAMING_SNAKE_CASE (A , A , A , A=None ) -> Union[str, Any]: """simple docstring""" lowercase__ = (path or []) + [u] for v in graph[u]: if visited_edge[u...
460
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _SCREAMING_SNAKE_CASE (A ) -> Dict: """simple docstring""" lowercase__ = os.path.join(args.tf_model_dir , ''...
460
1
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def a__ ( *_SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : Optional[Union[Dict, Any]] = None , _SCREAMING_SNAKE_CASE : ...
702
'''simple docstring''' from math import factorial _lowerCamelCase = {str(d): factorial(d) for d in range(10)} def a__ ( _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(_SCREAMING_SNAKE_CASE ...
323
0
"""simple docstring""" from __future__ import annotations def A_ ( snake_case__ ) -> bool: _UpperCamelCase :List[str] = str(snake_case_ ) return len(snake_case_ ) == 9 and set(snake_case_ ) == set('''123456789''' ) def A_ ( ) -> int | None: for...
355
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_, snake_case_=None, **snake_case_ ) -> Union[str, Any]: A__ : Optional[Any] =[x.strip() for x in open(snake_case_ ).readlines()] A__ :...
416
0
from collections import Counter from timeit import timeit def __UpperCAmelCase ( a_ = "" , ): return sum(c % 2 for c in Counter(input_str.replace(' ' , '').lower()).values()) < 2 def __UpperCAmelCase ( a_ = ""): if len(a_) == 0: return True s...
607
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tes...
607
1
'''simple docstring''' from __future__ import annotations from cmath import sqrt def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> tuple[complex, complex]: """simple docstring""" if a == 0: raise ValueError("""C...
26
'''simple docstring''' import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_...
26
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a = logging.get_logger(__name__) a = { """microsoft/focalnet-tiny""": """https://hug...
382
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileViTCo...
382
1
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken l...
413
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json""", # See all Donut...
507
0
import os def SCREAMING_SNAKE_CASE ( ) -> List[Any]: lowerCamelCase__ : int = os.path.dirname(os.path.realpath(_UpperCAmelCase ) ) lowerCamelCase__ : Any = os.path.join(_UpperCAmelCase , 'triangle.txt' ) with open(_UpperCAmelCase ) as f: l...
702
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, ...
188
0
import requests from bsa import BeautifulSoup def lowerCamelCase__ ( lowercase , lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Union[str, Any] = BeautifulSoup(requests.get(lowercase , params=lowercase ).content , "html.parser" ) SCRE...
62
"""simple docstring""" 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.pipeli...
473
0
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Toke...
680
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
1
"""simple docstring""" import string import numpy def snake_case ( _a: int , _a: int )-> int: '''simple docstring''' return b if a == 0 else greatest_common_divisor(b % a , _a ) class _a : a_ : str = string.ascii_uppercase + s...
510
"""simple docstring""" from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText ...
510
1
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(lowercase__ ), 'Tatoeba directory ...
713
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
23
0
'''simple docstring''' 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 lowercase_ = logging.get_logger(__name__) lowercase_ = {...
11
'''simple docstring''' import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import Th...
11
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value...
701
'''simple docstring''' import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename __A : Dic...
398
0
def __a ( lowerCAmelCase_ : int = 10_00 ) -> int: '''simple docstring''' UpperCAmelCase_, UpperCAmelCase_= 1, 1 UpperCAmelCase_= 2 while True: UpperCAmelCase_= 0 UpperCAmelCase_= fa + fa UpperCAmelCase_, UpperCAmelCase_...
593
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch_...
593
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixi...
715
"""simple docstring""" import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness __lowercase = """\ @misc{chen2021eval...
135
0
'''simple docstring''' def lowercase__ ( __lowercase : str ) -> int: """simple docstring""" assert column_title.isupper() __UpperCamelCase = 0 __UpperCamelCase = len(__lowercase ) - 1 __UpperCamelCase = 0 while index >= 0: ...
399
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Tuple = {'configuration_mmbt': ['MMBTConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opti...
98
0
from __future__ import annotations def a__ ( snake_case , snake_case ): """simple docstring""" # Checks if the entire collection has been sorted if len(snake_case ) <= 1 or n <= 1: return insert_next(snake_case , n - 1 ) rec_insertion_sort(snake_case ...
718
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning things...
131
0
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
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, ) lowerCAmelCase_ = { """configuration_clip""": [ """CLIP_PR...
411
0
from PIL import Image def __lowerCAmelCase ( UpperCamelCase ) -> Image: lowerCAmelCase__ : Any = image.size lowerCAmelCase__ : Dict = 0 lowerCAmelCase__ : Optional[Any] = image.load() for i in range(UpperCamelCase ): for j in r...
704
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ = { """configuration_longformer""": [ """LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
470
0
def a__ ( lowercase__ = 1_0 , lowercase__ = 2_2 ): '''simple docstring''' UpperCAmelCase_ =range(1 , lowercase__ ) UpperCAmelCase_ =range(1 , lowercase__ ) return sum( 1 for power in powers for base in bases if len(...
54
'''simple docstring''' import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) lowercase : Any = lo...
116
0
"""simple docstring""" from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, ...
712
"""simple docstring""" from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _snake_case ( ) -> Dict: '''simple docstring''' lowerCAmelCase_ :Optional[int] = HfArgumentParser(lowercase__ ) lower...
256
0
from __future__ import annotations __UpperCamelCase : Optional[Any] = list[list[int]] # assigning initial values to the grid __UpperCamelCase : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], ...
80
from __future__ import annotations from decimal import Decimal from numpy import array def lowercase ( SCREAMING_SNAKE_CASE ) -> list[list[float]]: '''simple docstring''' SCREAMING_SNAKE_CASE_ = Decimal # Check if the provided matrix has 2 rows and 2 columns # since...
205
0
"""simple docstring""" 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 a_ ( _UpperC...
19
"""simple docstring""" import re from filelock import FileLock try: import nltk a : str = True except (ImportError, ModuleNotFoundError): a : List[str] = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=True) def _UpperCamelCase ( ...
19
1
"""simple docstring""" import requests __lowerCamelCase = '' # <-- Put your OpenWeatherMap appid here! __lowerCamelCase = 'https://api.openweathermap.org/data/2.5/' def a ( __UpperCAmelCase : str = "Chicago" , __UpperCAmelCase : str = AP...
96
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
96
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, Bli...
127
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_: int = { 'configuration_trajectory_transformer': [ 'TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TrajectoryTransformerConfig', ...
127
1
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import Au...
65
"""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_avail...
65
1
"""simple docstring""" 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 UpperCamelCa...
463
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def snake_case ( A__ ): return np.dot(A__ ,A__ ) class UpperCamelCase_ : def __init__( self : int , *, lowerCAmelCase_ : ...
463
1
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex a__ : Optional[int] = logging.getLogger(__name__) class UpperCAmelCase_ : def __init__( self ): "...
188
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( _lowercase : list[float] , _lowercase : Tuple ) -> int: '''simple docstring''' print(f"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(_lowercase ): pri...
266
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_...
719
import math import unittest def _lowercase ( SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" assert isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < n...
181
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Tuple =logging.get_logger(__name__) __snake_case :str ={ 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json', 'microsoft/markuplm-large...
106
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.transforms.functional impo...
282
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf _lowerCamelCase : List[str] = ...
710
"""simple docstring""" import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": _lowerCamelCase : Optional[int] = argparse.ArgumentParser() parser.add_argument( ...
361
0
'''simple docstring''' from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTraini...
474
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers lowerCamelCase = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def _A ( ): """simple docstring""" __lowercase =os.path.dirname(os.path.realpath(_lowerCAmelCase ...
474
1
import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import A...
664
def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : Optional[Any] )->Any: # noqa: E741 _lowerCAmelCase = len(_SCREAMING_SNAKE_CASE ) _lowerCAmelCase = 0 _lowerCAmelCase = [0] * n _lowerCAmelCase = [False] * n _lowerCAmelCase = [False] * n def d...
664
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available()...
558
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_avail...
61
0
"""simple docstring""" def _lowerCAmelCase ( UpperCAmelCase__ : Optional[Any] ) ->int: 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] ) ): ...
712
"""simple docstring""" from timeit import timeit def _lowerCAmelCase ( UpperCAmelCase__ : int ) ->int: if number < 0: raise ValueError("""the value of input must not be negative""" ) A__ : Optional[int] = 0 while number: ...
498
0
'''simple docstring''' from __future__ import annotations UpperCamelCase__ : Optional[int] = 10 def lowerCAmelCase_ ( _lowerCamelCase: list[int] ): __SCREAMING_SNAKE_CASE : Any = 1 __SCREAMING_SNAKE_CASE : str = max(_lowerCamelCa...
578
'''simple docstring''' import math def lowerCAmelCase_ ( _lowerCamelCase: int ): __SCREAMING_SNAKE_CASE : Dict = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_lowerCamelCase ) def lowerCAmelCase_ ( _lowerCame...
578
1
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( snake_case_ : float , snake_case_ : float ) -> float: if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(snake_case_ ) * abs(snake_case_ ) if __na...
220
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'): __UpperCAmelCase = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Im...
220
1
from math import factorial def SCREAMING_SNAKE_CASE_ ( _snake_case :int = 100 ) -> int: return sum(int(_snake_case ) for x in str(factorial(_snake_case ) ) ) if __name__ == "__main__": print(solution(int(input("""Enter the Number: """).strip())))
2
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCAmelCase = {"""configuration_unispeech""": ["""UNISPEECH_PRETRAINED_CONFIG_ARCHIVE...
409
0
'''simple docstring''' import string from math import logaa def _lowerCAmelCase( UpperCAmelCase_ : str , UpperCAmelCase_ : str ) -> int: lowerCAmelCase__ = document.translate( str.maketrans("""""" , """""" , string.punctuation ) ).rep...
211
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=_A ): '''simple docstring''' A__ = ['''flax''', '''transformers'''] def __init__( self : List[str] , *__A : int , ...
211
1
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_i...
54
"""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 __snake_case ( __A : Union[str, Any] , __A : Any , __A : ...
265
0
'''simple docstring''' 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 : Tuple...
721
'''simple docstring''' from __future__ import annotations _UpperCAmelCase : str = 10 def UpperCamelCase ( lowercase_ : list[int] ) -> list[int]: '''simple docstring''' lowercase =1 lowercase =max(lowercase_ ) while placement <= max_digit: # declare...
145
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_ch...
672
'''simple docstring''' import numpy as np def snake_case_ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def snake_case_ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' return vector * sigmoid(1.702 *...
672
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean a__ : Tuple = 0 a__ : List[Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0...
235
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor a__ : int = transforms.Comp...
235
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( ): return [ a * b * (1_0_0_0 - a - b) for a in range(1 , 9_9_9 ) for b in range(__snake_case , 9_9_9 ) if (a * a + b * b == (1_0_0_0 - a - b) ** 2) ][0] if __name__ == "__main__": print(F'''{so...
107
def __UpperCamelCase (_SCREAMING_SNAKE_CASE ) -> Any: lowercase__ = [0] * len(_SCREAMING_SNAKE_CASE ) lowercase__ = [] lowercase__ = [1] * len(_SCREAMING_SNAKE_CASE ) for values in graph.values(): for i in values: ...
235
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resiz...
719
'''simple docstring''' from statistics import mean, stdev def snake_case_ ( a__ : list ,a__ : int = 3 ): """simple docstring""" __lowercase = min(a__ ) __lowercase = max(a__ ) # normalize data return [round((x - x_...
163
0
def lowerCAmelCase_ ( _lowercase : list , _lowercase : int , _lowercase : int = 0 , _lowercase : int = 0) -> int: """simple docstring""" a__ : str = right or len(_lowercase) - 1 if left > right: return -1 elif list_dat...
136
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImgaImgPipel...
136
1
'''simple docstring''' import math def __a ( __lowerCamelCase : Tuple , __lowerCamelCase : List[str] ) -> List[Any]: '''simple docstring''' if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(__lowerCame...
461
'''simple docstring''' from __future__ import annotations def __a ( __lowerCamelCase : int | str ) -> bool: '''simple docstring''' lowercase_ = str(__lowerCamelCase ) return n == n[::-1] def __a ( __lowerCamelCase : int = 1_000_000 ) -> Optional[int]:...
461
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : List[str] = logging.get_logger(__name__) UpperCAmelCase__ : str = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.jso...
410
__UpperCAmelCase : int = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)] def lowerCamelCase_ ( UpperCamelCase_ ): _a : Optional[Any] = 0 while number: # Increased Speed Slightly by checking every 5 digits together. su...
471
0
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import ...
636
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import conv...
636
1
"""simple docstring""" from heapq import heappop, heappush import numpy as np def UpperCAmelCase__ ( lowerCAmelCase__ :List[str] , lowerCAmelCase__ :List[Any] , lowerCAmelCase__ :List[str] , lowerCAmelCase__ :Dict , ) -> List[str]: '''simple...
359
def __lowerCAmelCase ( A , A ): UpperCAmelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def __lowerCAmelCase ( A , A , A ): UpperCAmelCase_ = 0 while b > 0: if b & 1: UpperCAmelCase_ =...
162
0
'''simple docstring''' 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 __lowercase = { "g...
707
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowercase = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileNetV2Config...
305
0
from copy import deepcopy class __A: def __init__( self , _snake_case = None , _snake_case = None ) -> None: '''simple docstring''' if arr is None and size is not None: __a = size __a = [0] * size ...
219
def __lowerCAmelCase ( a__ , a__ ) -> None: __a = len(a__ ) print('''The following activities are selected:''' ) # The first activity is always selected __a = 0 print(a__ , end=''',''' ) # Consider rest of the activitie...
219
1
'''simple docstring''' __lowerCamelCase : str = 8.314_4598 def UpperCAmelCase_ ( lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: ...
708
'''simple docstring''' # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tes...
459
0
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def lowerCAmelCase__ ( a__: Union[str, Any] ) -> Any: '''simple docstring''' _UpperCAmelCase = SwinConf...
618
from sklearn.metrics import matthews_corrcoef import datasets a__ : Any = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true a...
622
0
'''simple docstring''' def __snake_case (__UpperCAmelCase , __UpperCAmelCase ): """simple docstring""" _enforce_args(__UpperCAmelCase , __UpperCAmelCase ) if n == 0: return 0 lowerCamelCase_ : Optional[Any] = float('''-inf''' ) for i in range(1 ...
418
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]...
418
1
import os def lowerCamelCase__ ( __A :str = "input.txt" ): """simple docstring""" with open(os.path.join(os.path.dirname(__A ) ,__A ) ) as input_file: __snake_case = [ [int(__A ) for element in line.split(""...
268
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transform...
268
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 _UpperCAmelCase : List[Any] =logging.get_logger(__name__...
702
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import...
619
0
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __magic_name__ ( lowercase_ , lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> Dict: '''simple docstring''' UpperCam...
606
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def _UpperCAmelCase ( A , A=7 ): '''simple docstring''' UpperCAmelCase__ =None if token is not None: UpperCAmelCase__ ...
625
0
def __lowerCAmelCase ( __magic_name__ ): if len(__magic_name__ ) < 2: return collection def circle_sort_util(__magic_name__ , __magic_name__ , __magic_name__ ) -> bool: _lowercase: int = False if low == high: return swapped _lowercase: str = ...
206
_SCREAMING_SNAKE_CASE : dict[tuple[int, int, int], int] = {} def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: return 0 ...
206
1
def __a ( __lowerCAmelCase ) -> str: SCREAMING_SNAKE_CASE : int = [0] * len(__snake_case ) SCREAMING_SNAKE_CASE : Optional[int] = [] SCREAMING_SNAKE_CASE : Union[str, Any] = [] SCREAMING_SNAKE_CASE : s...
352
def _A ( __snake_case :bytes ) -> str: """simple docstring""" return "".join([hex(__snake_case )[2:].zfill(2 ).upper() for byte in list(__snake_case )] ) def _A ( __snake_case :str ) -> bytes: """simple docstring""" if (len(__sna...
693
0
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbon...
368
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef __magic_name__ : List[str] = ( """This metric will be removed...
368
1
A : Optional[Any] = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def UpperCamelCase ( __magic_name__ : int ) -> int: """simple docstring""" lowercase__ = 0 while number: # Increased Speed Slightly by checkin...
15
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''roberta-base''': '''https://huggingface.co/roberta-b...
282
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json''' ...
452
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available __lowercase = { '''configuration_audio_spectrogram_transformer''': [ '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ASTC...
452
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, Conditiona...
328
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not ...
328
1
"""simple docstring""" from ....utils import logging _A = logging.get_logger(__name__) class lowerCamelCase (_SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self : List[Any] , _snake_case : Optional[int] , _snake_case : ...
538
"""simple docstring""" from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabe...
538
1
import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMix...
87
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging _lowerCamelCase : int = logging.get_logger(__name__) def SCREAMING_SNAKE_CASE ( lowercase_ , low...
87
1
"""simple docstring""" import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_s...
48
"""simple docstring""" import random def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : bool = False ): """simple docstring""" snake_case_ : dict = {i: [] for i in range(SCREAMING...
48
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, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
644
"""simple docstring""" def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" return abs(lowerCamelCase__ ) if a == 0 else greatest_common_divisor(b % a , lowerCamelCase__ ) def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCa...
644
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, prep...
555
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_singl...
555
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
646
# Lint as: python3 import itertools import os import re _lowercase = re.compile(r'''([A-Z]+)([A-Z][a-z])''') _lowercase = re.compile(r'''([a-z\d])([A-Z])''') _lowercase = re.compile(r'''(?<!_)_(?!_)''') _lowercase = re.compile(r'''(_{2,})''') _lowercase = r'''^\w+(\.\w+)*...
157
0
'''simple docstring''' from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def __a ( __lowerCamelCase : int ) -> bool: '''simple docstring''' lowercase_ = int(number**0.5 ) return number == sq * sq def __a ( __lowerCamelCase ...
461
'''simple docstring''' from __future__ import annotations def __a ( __lowerCamelCase : int | str ) -> bool: '''simple docstring''' lowercase_ = str(__lowerCamelCase ) return n == n[::-1] def __a ( __lowerCamelCase : int = 1_000_000 ) -> Optional[int]:...
461
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...
108
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a_ : Tuple = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} ...
623
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_m...
716
"""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 OptionalDependencyNotAvailabl...
87
0
import numpy as np from transformers import Pipeline def _lowerCAmelCase ( UpperCamelCase__: Optional[Any] ) -> Optional[int]: """simple docstring""" A = np.max(UpperCamelCase__ , axis=-1 , keepdims=UpperCamelCase__ ) A = np.exp(out...
641
# 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 applic...
641
1
import math def lowercase ( SCREAMING_SNAKE_CASE__ : Union[str, Any] = 100 ) -> int: _snake_case : Union[str, Any] = sum(i * i for i in range(1 , n + 1 ) ) _snake_case : Union[str, Any] = int(math.pow(sum(range(1 , n + 1 )...
710
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_ca...
198
0
from sklearn.metrics import fa_score import datasets SCREAMING_SNAKE_CASE__ : 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) ''' SCREAMING_SNAKE_CASE__ : Tuple ...
85
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ : int = 2_00_00_00 ) -> int: _lowercase = [0 for i in range(n + 1 )] _lowercase = 1 _lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_lis...
287
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if i...
720
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = '▁' _UpperCAme...
240
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() exce...
76
"""simple docstring""" import csv import tweepy # Twitter API credentials __A = """""" __A = """""" __A = """""" __A = """""" def __A (_SCREAMING_SNAKE_CASE ) ->None: """simple docstring""" lowerCAmelCase__ :Any ...
93
0
def snake_case__ ( ): A : Any = 0 for i in range(1 , 1001 ): total += i**i return str(lowerCamelCase_ )[-10:] if __name__ == "__main__": print(solution())
423
def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): return x if y == 0 else greatest_common_divisor(lowerCamelCase_ , x % y ) def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): return (x * y) // greatest_common_divisor(lowerCa...
423
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Any ={ """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConfig""", """CLIPSegTextConfig""", ...
54
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCamelCase__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: ...
225
0
'''simple docstring''' from __future__ import annotations def A (__lowerCamelCase :list[int] ): if len(__lowerCamelCase ) == 0: return array _lowerCAmelCase , _lowerCAmelCase = min(__lowerCamelCase ), max(__lowerCamelCase ) # Compute the variables ...
716
'''simple docstring''' from __future__ import annotations def A (__lowerCamelCase :list[int] ): if len(__lowerCamelCase ) == 0: return array _lowerCAmelCase , _lowerCAmelCase = min(__lowerCamelCase ), max(__lowerCamelCase ) # Compute the variables _lowerCAm...
162
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class __A : def __init__( self : Dict ) -> Optional[Any]: __magic_name__: Dict = {} def lowe...
96
"""simple docstring""" from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a :str = 637_8137.0 a :Optional[Any] = 635_6752.31_4245 a :List[Any] = 6_378_137 def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ,...
680
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_d...
716
"""simple docstring""" import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase : Dict =logging.get_logge...
237
0
'''simple docstring''' def A_ ( _lowerCamelCase : list ): if len(__A ) < 2: return collection def circle_sort_util(_lowerCamelCase : list , _lowerCamelCase : int , _lowerCamelCase : int ) -> bool: _lowerCAmelCase = False ...
309
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class A_ ( ...
485
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def __A ( lowerCamelCase_ ): """simple docstring""" if ( (cp >= 0x4e00 and cp <= 0x9fff) or (cp >= 0x3400 and cp...
719
'''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(): ...
79
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_mod...
94
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : Optional[Any] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kineti...
602
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, ...
711
import sys from collections import defaultdict class snake_case__ : def __init__( self : List[Any] ): snake_case__ : Dict = [] def UpperCAmelCase__ ( self : List[str] , _lowerCamelCase : Tuple ): ...
303
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { '''facebook/convnextv2-tiny-1k...
351
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCAmelCase_ ( *__A ) -> Dict: '''simple docstring''' if not isinstance(__A, __A ): UpperCAmelCase__ = list(_...
486
0
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 loggin...
243
def lowercase_ (A : Optional[int]=2_8_1_2_3 ): snake_case__ : Any = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_divs[k * ...
243
1
"""simple docstring""" # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _lowerCamelCase ( UpperCAmelCase_ : Any, UpperCAmelCase_ : Any, UpperCAmelCase_ : List[Any], UpperCAmelCase_ : List[str] ) -> int: ...
104
'''simple docstring''' import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class A ( pl.LightningModule ): def __init__( self : Dict , __a : List[str] ...
262
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 __a ( A_ , unittest.TestCase ):...
708
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils i...
97
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : List[str] = logging.get_logger(__name__) snake_case : List[Any] = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json', ...
566
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule snake_case : Optional[Any] = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys snake_case...
566
1
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def __lowerCamelCase ( __a :str = "laptop" ) -> DataFrame: """simple docstring""" A__ = F'https://www.amazon.in/lapto...
247
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate imp...
247
1
'''simple docstring''' import os from datetime import datetime as dt from github import Github __UpperCAmelCase = [ "good first issue", "feature request", "wip", ] def lowerCAmelCase_ ( ): '''simple docstring''' snake_case: Tuple = Github...
329
'''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=snake_case , slots=snake_case ) class SCREAMING...
329
1
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_co...
255
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase =logging.get_logger(__name__) UpperCAmelCase ={ "google/umt5-small": "https://huggingfa...
255
1
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __lowerCamelCase ( ...
61
def SCREAMING_SNAKE_CASE__ ( snake_case_ = "The quick brown fox jumps over the lazy dog", ) -> bool: """simple docstring""" a = set() # Replace all the whitespace in our sentence a = input_str.replace(''' ''', '''''' ) for alpha in input_str: if...
387
0
def UpperCAmelCase ( lowercase__ : int ): '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < 0: raise ValueError("""multiplicative_persistence() doe...
412
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_auto impo...
412
1