code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class lowercase ( SCREAMING_SNAKE_CASE__ ): def A__ ( self ,A__): return 0.0 def UpperCamelCase ( lowerCAmelCase_...
101
"""simple docstring""" import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( ) -> Tuple: from torch.utils.cpp_extension import load A__ = Path(lowercase_ ).resolve().parent.parent.parent / "kernels" / "deformable_detr" A__ = [ root / filename ...
247
0
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE : str = 2_9979_2458 # Symbols SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Dict ...
102
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging logg...
103
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
'''simple docstring''' from __future__ import annotations from math import gcd def _A ( A__ , A__ = 2 , A__ = 1 , A__ = 3 , ): """simple docstring""" if num < 2: raise ValueError('''The input value cannot be less than 2''' ) # Because of the relationsh...
104
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters SCREAMING_SNAKE_CASE = (720, 1280) # Height, Width SCREAMING_SNAKE_CASE = (0.4, 0.6) # if height or width lower than this scale, drop it. SCREAM...
247
0
"""simple docstring""" import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __UpperCamelCase ( a__ , a__ ): @register_to_config def __init__( sel...
105
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE = "src/diffusers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re....
247
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=a_ ): """simple docstring""" lowercase__ = ["flax", "transformers"] def __init__( self : int ,*lowercase_ : List[str] ...
106
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> List[str]: A__ = len(lowercase_ ) while cur > 1: # Find the maximum number in arr A__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A__ = arr[mi::-1] + arr[mi + 1 :...
247
0
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler,...
107
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
0
"""simple docstring""" from statistics import mean import numpy as np def a__ ( SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCa...
108
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_p...
247
0
"""simple docstring""" def _snake_case ( UpperCamelCase : str ): UpperCAmelCase : str = [0] * len(UpperCamelCase ) for i in range(1 , len(UpperCamelCase ) ): # use last results for better performance - dynamic programming UpperCAmelCase : int = prefix_resu...
109
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : int = logging.get_logger(__name__) _lowerCamelCase : Tuple = { "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/...
336
"""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_MAPPI...
247
0
from __future__ import annotations import bisect def UpperCamelCase__ ( A__ , A__ , A__ = 0 , A__ = -1 ) -> int: if hi < 0: snake_case__ : int = len(lowercase_ ) while lo < hi: snake_case__ : Union[str, Any] = lo + (hi ...
143
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing import Poly...
283
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
247
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase ): """simple docstring""" global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: lowerCAmelCa...
37
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
247
0
from __future__ import annotations lowerCamelCase = 10 def lowerCamelCase_ ( _a ): """simple docstring""" lowerCAmelCase__ : int = 1 lowerCAmelCase__ : Any = max(lowercase_ ) while placement <= max_digi...
131
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: if length <= 0 or not isinstance(lowercase_ , lowercase_ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(lowercase_ )] if __name__ == "__ma...
247
0
import argparse import hashlib # hashlib is only used inside the Test class import struct class A__ : def __init__( self , A_ ): '''simple docstring''' UpperCamelCase : Dict = data UpperCamelCase : Tuple = [0x6_7_4_5_2_3_0_1, 0...
52
"""simple docstring""" import qiskit def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> qiskit.result.counts.Counts: A__ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register A__ = qiskit.QuantumCircuit(lower...
247
0
def lowerCAmelCase__(__snake_case ) -> list: '''simple docstring''' lowerCamelCase__ = len(lowercase_ ) for i in range(1 ,lowercase_ ): lowerCamelCase__ = collection[i] lowerCamelCase__ = 0 lowerCamelCase__ = i - 1 while low...
209
"""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-...
247
0
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ = True , UpperCAmelCase_ = math.inf , UpperCAmelCase_ = -math.inf , UpperCAmelCase_ = math.inf...
151
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif...
247
0
"""simple docstring""" import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import Padding...
243
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ...
247
0
"""simple docstring""" def lowercase ( A_ )-> List[str]: '''simple docstring''' a : List[Any] = len(lowercase_ ) while cur > 1: # Find the maximum number in arr a : int = arr.index(max(arr[0:cur] ...
40
"""simple docstring""" 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 acceler...
247
0
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if...
259
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentP...
247
0
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class __UpperCAmelCase ( nn.Module ): def __init__( self : Any, __A : int = 1_6, __A : int = 8_8, __A : Optional[i...
336
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
0
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_...
143
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preproce...
247
0
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.uti...
283
"""simple docstring""" import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( ) -> Tuple: from torch.utils.cpp_extension import load A__ = Path(lowercase_ ).resolve().parent.parent.parent / "kernels" / "deformable_detr" A__ = [ root / filename ...
247
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class lowerCAmelCase...
37
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_ax...
131
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig __lowerCamelCase : List[Any] = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albert-large-...
52
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters SCREAMING_SNAKE_CASE = (720, 1280) # Height, Width SCREAMING_SNAKE_CASE = (0.4, 0.6) # if height or width lower than this scale, drop it. SCREAM...
247
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _a = logging.g...
209
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE = "src/diffusers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re....
247
0
'''simple docstring''' def UpperCamelCase( UpperCAmelCase_ ): if n_term == "": return [] UpperCAmelCase : List[str] = [] for temp in range(int(lowercase_ ) ): series.append(F"""1/{temp + 1}""" if series else '1' ) return series if __name__ == "__main__": lowercase__...
151
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> List[str]: A__ = len(lowercase_ ) while cur > 1: # Find the maximum number in arr A__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A__ = arr[mi::-1] + arr[mi + 1 :...
247
0
"""simple docstring""" from pathlib import Path import fire def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Tuple: """simple docstring""" a_ = Path(lowercase_ ) a_ = Path(lowercase_ ) dest_dir.mkdir(exist_ok=lowercase_ ) ...
243
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
0
"""simple docstring""" from __future__ import annotations __lowercase = 8.988e9 # units = N * m^s * C^-2 def lowercase ( A_ , A_ , A_ , A_ )-> dict[str, float]: '''simple docstring''' a : Optional[int] = abs...
40
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_p...
247
0
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Dict , SCREAMING_SNAKE_CASE__ : Optional[Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : int , ): UpperCamelCase :List[Any] = len(lo...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow # s...
336
"""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_MAPPI...
247
0
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging lowerCAmelCase__ :...
143
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
from pathlib import Path import json import tempfile from transformers import FSMTTokenizer, FSMTConfig, FSMTForConditionalGeneration from transformers.models.fsmt.tokenization_fsmt import VOCAB_FILES_NAMES _snake_case = '''tiny-wmt19-en-ru''' # Build # borrowed from a test _snake_...
283
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
247
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { '''configuration_blip_2''': [ '''BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Blip2Config''', '''Blip2QFormer...
37
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
247
0
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def lowerCamelCase_ ( ): """simple docstring""" lowerCAmelCase__ : int = { '''repo_name''': ['''...
131
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: if length <= 0 or not isinstance(lowercase_ , lowercase_ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(lowercase_ )] if __name__ == "__ma...
247
0
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO, ) __lowerCamelCase : Optional[int]...
52
"""simple docstring""" import qiskit def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> qiskit.result.counts.Counts: A__ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register A__ = qiskit.QuantumCircuit(lower...
247
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
209
"""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-...
247
0
'''simple docstring''' import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pi...
151
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif...
247
0
"""simple docstring""" import functools from typing import Any def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ) ->bool: """simple docstring""" if not isinstance(lowercase_ , lowercase_ ) or len(lowercase_ ) == 0: raise ValueError("the string should be not empt...
243
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ...
247
0
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowercase ( A_ )-> bool: '''simple docstring''' a : Dict = int(number**0.5 ) return number == sq * s...
40
"""simple docstring""" 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 acceler...
247
0
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_avail...
259
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentP...
247
0
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 _lowerCamelCase : Optional[Any] = "http://www.mocksi...
336
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
0
lowerCAmelCase__ : Tuple = [0, 2, 4, 6, 8] lowerCAmelCase__ : Union[str, Any] = [1, 3, 5, 7, 9] def UpperCamelCase__ ( A__ , A__ , A__ , A__ ) -> int: if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return 0 for i in range...
143
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preproce...
247
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_...
283
"""simple docstring""" import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( ) -> Tuple: from torch.utils.cpp_extension import load A__ = Path(lowercase_ ).resolve().parent.parent.parent / "kernels" / "deformable_detr" A__ = [ root / filename ...
247
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...
37
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = {'''vocab_...
131
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def A_ ( ) -> Dict: raise RuntimeError("CUDA out of memory." ) class A__ ( nn.Module ): ...
52
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters SCREAMING_SNAKE_CASE = (720, 1280) # Height, Width SCREAMING_SNAKE_CASE = (0.4, 0.6) # if height or width lower than this scale, drop it. SCREAM...
247
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/config.json", "funnel-transformer/small-base": "https://huggingface.c...
209
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE = "src/diffusers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re....
247
0
'''simple docstring''' import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ =...
151
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> List[str]: A__ = len(lowercase_ ) while cur > 1: # Find the maximum number in arr A__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A__ = arr[mi::-1] + arr[mi + 1 :...
247
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, ControlNetModel, DDIMScheduler, StableDiffusionContro...
243
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
0
"""simple docstring""" 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 AutoFeatureExtractor, WavaVecaFeatureExtractor fro...
40
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_p...
247
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailable() exce...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
from manim import * class __UpperCAmelCase ( A_ ): def __magic_name__ ( self : List[Any] ): UpperCAmelCase : Union[str, Any] = Rectangle(height=0.5, width=0.5 ) UpperCAmelCase : Optional[int] = Rectangle(height=0.4...
336
"""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_MAPPI...
247
0
import inspect import unittest from transformers import MobileNetVaConfig 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 import ConfigTester from ...
143
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_cas...
283
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
247
0
'''simple docstring''' from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" return ConvertCommand( args.model_type , args.tf_checkpoi...
37
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
247
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _a ( A...
131
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: if length <= 0 or not isinstance(lowercase_ , lowercase_ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(lowercase_ )] if __name__ == "__ma...
247
0
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester fro...
52
"""simple docstring""" import qiskit def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> qiskit.result.counts.Counts: A__ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register A__ = qiskit.QuantumCircuit(lower...
247
0
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCAmelCase__(__snake_case = "" ) -> dict[str, float]: '''simple docstring''' lowerCamelCase__ = url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250''' lowerCamelCa...
209
"""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-...
247
0
'''simple docstring''' from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState f...
151
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif...
247
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { 'configuratio...
243
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ...
247
0
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynam...
40
"""simple docstring""" 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 acceler...
247
0
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): """simple docstring""" UpperCamelCase_ : Dict ='Speech2TextFeatureExtractor' UpperCamelCase_ : Dict ='Speec...
259
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentP...
247
0
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __UpperCAmelCase ( A_ ):...
336
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
0
import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowerCAmelCase__ : List[str] = '''src/transformers''' # This is to make sure the transformers mo...
143
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preproce...
247
0
import operator as op _snake_case = '''scaler.pt''' _snake_case = '''pytorch_model''' _snake_case = '''random_states''' _snake_case = '''optimizer''' _snake_case = '''scheduler''' _snake_case = '''pytorch_mod...
283
"""simple docstring""" import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( ) -> Tuple: from torch.utils.cpp_extension import load A__ = Path(lowercase_ ).resolve().parent.parent.parent / "kernels" / "deformable_detr" A__ = [ root / filename ...
247
0
'''simple docstring''' import sys from pathlib import Path _lowerCAmelCase = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import itertools # noqa import json # noqa import os # noqa import unittest # noqa f...
37
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
import torch def lowerCamelCase_ ( ): """simple docstring""" if torch.cuda.is_available(): lowerCAmelCase__ : Optional[Any] = torch.cuda.device_count() else: lowerCAmelCase__ : str = 0 print(f'Successfully ran on ...
131
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class A__ : def __init__( self ): '''simple docstring''' UpperCamelCase : Any = "" UpperCamelCase : Union[str, Any] = "" UpperCamelCase : U...
52
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters SCREAMING_SNAKE_CASE = (720, 1280) # Height, Width SCREAMING_SNAKE_CASE = (0.4, 0.6) # if height or width lower than this scale, drop it. SCREAM...
247
0
def lowerCAmelCase__(__snake_case = 1000 ) -> int: '''simple docstring''' lowerCamelCase__ = 2**power lowerCamelCase__ = 0 while n: lowerCamelCase__ , lowerCamelCase__ = r + n % 10, n // 10 return r if __name__ == "__main__": print(solution(int(st...
209
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE = "src/diffusers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re....
247
0
'''simple docstring''' import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.ja...
151
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> List[str]: A__ = len(lowercase_ ) while cur > 1: # Find the maximum number in arr A__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A__ = arr[mi::-1] + arr[mi + 1 :...
247
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ] } try: if not is_to...
243
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
0
"""simple docstring""" import string def lowercase ( A_ )-> None: '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): a : List[str] = "" for symbol in message: if symbol in string.asci...
40
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_p...
247
0
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE_...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py _lowerCamelCase : Dict = "src/diffusers" # Matches is_xxx_available() _lowerCamelCase : Any = re.compile(...
336
"""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_MAPPI...
247
0
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def UpperCamelCase__ ( A__ = True , *A__ , **A__ ) -> int: if not is_tqdm_available(): raise ImportError('Accelerate\'s `tqdm` module requ...
143
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
def lowercase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' lowerCamelCase : Tuple = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
283
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
247
0
'''simple docstring''' import math class lowerCAmelCase_: '''simple docstring''' def __init__( self ,__UpperCAmelCase=0 ) -> List[str]: # a graph with Node 0,1,...,N-1 lowerCAmelCase__ : Union[str, Any] = n lowerCAmelCase__ : Dict = ...
37
"""simple docstring""" import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights ...
247
0
import numpy as np def lowerCamelCase_ ( _a ): """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
131
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: if length <= 0 or not isinstance(lowercase_ , lowercase_ ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(lowercase_ )] if __name__ == "__ma...
247
0
from __future__ import annotations __lowerCamelCase : Any = """#""" class A__ : def __init__( self ): '''simple docstring''' UpperCamelCase : str = {} def __UpperCamelCase( self , A_ ): '''simple docstrin...
52
"""simple docstring""" import qiskit def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> qiskit.result.counts.Counts: A__ = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register A__ = qiskit.QuantumCircuit(lower...
247
0
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils impor...
209
"""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-...
247
0
'''simple docstring''' from __future__ import annotations class A_ : '''simple docstring''' def __init__( self : str , lowercase_ : int = 0 ) -> List[Any]: UpperCAmelCase : int = key def UpperCAmelCase_ ...
151
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif...
247
0
"""simple docstring""" import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor fr...
243
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase_ ...
247
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from...
40
"""simple docstring""" 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 acceler...
247
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case = { """configuration_blenderbot""": [ """BLENDERBOT_PRETRAINED_CO...
259
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentP...
247
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def a__ ( UpperCAmelCase : str ) -> int: UpperCAmelCase : List[str] = prime_factors(lowercase_ ) if is_square_free(lowercase_ ): return -1 if len(lowercase_ ) % 2 else 1 ...
336
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
0
def UpperCamelCase__ ( A__ , A__ , A__ ) -> int: if exponent == 1: return base if exponent % 2 == 0: snake_case__ : Any = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
143
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preproce...
247
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class UpperCAmelCase_ ( A_ ): '''simple docstring''' def __init__( self , __A , __A , __A ): """simple docstr...
283
"""simple docstring""" import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( ) -> Tuple: from torch.utils.cpp_extension import load A__ = Path(lowercase_ ).resolve().parent.parent.parent / "kernels" / "deformable_detr" A__ = [ root / filename ...
247
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): # noqa: E741 """simple docstring""" lowerCAmelCase__ : List[Any] = len(lowercase_ ) lowerCAmelCase__ : Union[str, Any] = 0 lowerCAmelCase__ : int = [0] ...
37
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = { '''configuration_vision_text_dual_encoder''': ['''VisionTextDualEncoderConfig'''], '''...
131
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_ava...
247
0
def A_ ( _lowerCAmelCase , _lowerCAmelCase ) -> float: return price * (1 + tax_rate) if __name__ == "__main__": print(f"""{price_plus_tax(100, 0.2_5) = }""") print(f"""{price_plus_tax(1_2_5.5_0, 0.0_5) = }""")
52
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters SCREAMING_SNAKE_CASE = (720, 1280) # Height, Width SCREAMING_SNAKE_CASE = (0.4, 0.6) # if height or width lower than this scale, drop it. SCREAM...
247
0
def lowerCAmelCase__(__snake_case ) -> Optional[int]: '''simple docstring''' for i in range(0 ,lowercase_ ): for _ in range(0 ,n - i - 1 ): # printing spaces print(''' ''' ,end='''''' ) for _ in range(0 ,i + 1 ): # printing sta...
209
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py SCREAMING_SNAKE_CASE = "src/diffusers" # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re....
247
0
'''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, ) ...
151
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> List[str]: A__ = len(lowercase_ ) while cur > 1: # Find the maximum number in arr A__ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A__ = arr[mi::-1] + arr[mi + 1 :...
247
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { 'configuration_xlm_roberta_xl': [ 'XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMRobertaXLConfig', 'XLMRob...
243
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(lowercase_ , exponent // 2 , lowercase_ ) % modulo_value return (x * x) % modulo_value else: ...
247
0
"""simple docstring""" import math import tensorflow as tf from packaging import version def lowercase ( A_ )-> Union[str, Any]: '''simple docstring''' a : int = tf.convert_to_tensor(lowercase_ ) a : Union[str, Any...
40
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_p...
247
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCAmelCase_ ( unittest.TestCase ): """simple ...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
class __UpperCAmelCase : def __init__( self : List[Any], __A : list ): UpperCAmelCase : str = set_counts UpperCAmelCase : Union[str, Any] = max(snake_case_ ) UpperCAmelCase : str = len(snake_case_ ) Upp...
336
"""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_MAPPI...
247
0
def UpperCamelCase__ ( A__ ) -> list[int]: if num <= 0: raise ValueError('Input must be a positive integer' ) snake_case__ : Union[str, Any] = [True] * (num + 1) snake_case__ : Optional[int] = 2 while p * p <= num: ...
143
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, ...
283
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
247
0