code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE__ = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallba...
9
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
1
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def _a ( self : str ): """simple docstring""" A__ = get_ac...
9
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
1
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.compile(r'''is\_([a-z_]...
9
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
9
1
import numpy as np import datasets SCREAMING_SNAKE_CASE__ = ''' Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was introduced by Prof. ...
9
from __future__ import annotations from typing import Any def A ( __UpperCamelCase ) -> int: if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [] for token in postfix_notation: if token in operations: A__ , A__ = stack.p...
9
1
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A ( __UpperCamelCase ) -> Op...
9
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
1
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switch...
9
from __future__ import annotations from fractions import Fraction def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( __UpperCamelCase ) -> list[str]:...
9
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def A ( ) -> Union[str, Any]: A__ = HfArgumentParser(__UpperCamelCase ) A__ = parser.parse_args_into_dataclasses()[0] A__ = TensorFlowBenchmark(args=__UpperCamelCase ) ...
9
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
1
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def A ( __UpperCamelCase , __UpperCamelCase=7 ) -> Optional[int]: A__ = None if token is not None: A__ = {'Accept': 'application/vnd.github+json',...
9
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable SCREAMING_SNAKE_CASE__ = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try: ...
9
def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(__UpperCamelCase , exponent // 2 , __UpperCamelCase ) % modulo_value return (x * x) % modul...
9
1
import math def A ( __UpperCamelCase , __UpperCamelCase ) -> float: if initial_intensity < 0: raise ValueError('The value of intensity cannot be negative' ) # handling of negative values of initial intensity if angle < 0 or angle > 360: raise ValueError('I...
9
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
1
# flake8: noqa # Lint as: python3 SCREAMING_SNAKE_CASE__ = [ '''VerificationMode''', '''Version''', '''disable_progress_bar''', '''enable_progress_bar''', '''is_progress_bar_enabled''', '''experimental''', ] from .info_utils import VerificationMode from .logging import disable_progre...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
9
def A ( __UpperCamelCase , __UpperCamelCase ) -> Optional[int]: A__ = 0 A__ = len(__UpperCamelCase ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: if sorted_collec...
9
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time SCREAMING_SNAKE_CASE__ = Lock() def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , ...
9
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *_snake_cas...
9
1
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex SCREAMING_SNAKE_CASE__ = logging.getLogger(__name__) class __lowerCAmelCase : """simple docstring""" def __init__( s...
9
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
9
1
def A ( __UpperCamelCase = 4_000_000 ) -> int: A__ = [0, 1] A__ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 A__ = 0 for j in range(len(__UpperCamelCase ) - 1 ): if fib[...
9
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
9
1
def A ( __UpperCamelCase ) -> tuple[int, int]: try: A__ = float(__UpperCamelCase ) except ValueError: raise ValueError('Please enter a valid number' ) A__ = decimal - int(__UpperCamelCase ) if fractional_part == 0: return int(__UpperCam...
9
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
9
1
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutput...
9
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFo...
9
1
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class __lowerCAmelCase ( UpperCAmelCase_ , unittest.TestCase ): ...
9
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE__ = '''docs/source/en/_toctree.yml''' def A ( __UpperCamelCase ) -> Optional[Any]: A__ = defaultdict(__UpperCamelCase ) for doc in model_doc: counts[doc["local"]] += 1 A__ ...
9
1
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''kakaobrain/align-base''': '''...
9
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
9
1
from datetime import datetime import matplotlib.pyplot as plt import torch def A ( __UpperCamelCase ) -> Any: for param in module.parameters(): A__ = False def A ( ) -> str: A__ = 'cuda' if torch.cuda.is_available() else 'cpu' if torch.backends.mps.i...
9
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A ( __UpperCamelCase ) -> Op...
9
1
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core....
9
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
9
1
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Tuple , _snak...
9
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
1
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreT...
9
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
1
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
9
1
from collections import defaultdict def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: A__ = first_str.lower().strip() A__ = second_str.lower().strip() # Remove whitespace A__ = first_str.replace(' ' , '' ) A__ = second_str.replac...
9
from __future__ import annotations from typing import Any def A ( __UpperCamelCase ) -> int: if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [] for token in postfix_notation: if token in operations: A__ , A__ = stack.p...
9
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.js...
9
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig 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_commo...
9
from __future__ import annotations from fractions import Fraction def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( __UpperCamelCase ) -> list[str]:...
9
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']} try:...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
import math def A ( __UpperCamelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number ...
9
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
1
from __future__ import annotations def A ( __UpperCamelCase , __UpperCamelCase ) -> list[str]: if partitions <= 0: raise ValueError('partitions must be a positive number!' ) if partitions > number_of_bytes: raise ValueError('partitions can not > number_of_bytes!'...
9
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
1
def A ( __UpperCamelCase , __UpperCamelCase ) -> list[str]: return [sentence[i : i + ngram_size] for i in range(len(__UpperCamelCase ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
9
def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(__UpperCamelCase , exponent // 2 , __UpperCamelCase ) % modulo_value return (x * x) % modul...
9
1
import warnings from .generation import TFGenerationMixin class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transformers v5...
9
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
1
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowerCAmelCase ( UpperCAmelCase_ ): ""...
9
def A ( __UpperCamelCase , __UpperCamelCase ) -> Optional[int]: A__ = 0 A__ = len(__UpperCamelCase ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: if sorted_collec...
9
1
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets....
9
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *_snake_cas...
9
1
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __lowerCAmelCase : """simple docstring""" def _a ( self : Dict , _snake_case : List[str] ): ...
9
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
9
1
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_r...
9
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
9
1
from __future__ import annotations import math def A ( __UpperCamelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes r...
9
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
9
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorType...
9
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFo...
9
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
9
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE__ = '''docs/source/en/_toctree.yml''' def A ( __UpperCamelCase ) -> Optional[Any]: A__ = defaultdict(__UpperCamelCase ) for doc in model_doc: counts[doc["local"]] += 1 A__ ...
9
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { '''configuration_luke''': ['''LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LukeConfig'''], '''tokenization_luke''': ['''LukeTokenizer'''], } try: if...
9
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
9
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
9
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A ( __UpperCamelCase ) -> Op...
9
1
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE__ = get_tests_dir('''fixtur...
9
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
9
1
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 from accelerate.test_utils import Reg...
9
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
1
from collections import defaultdict def A ( __UpperCamelCase ) -> int: A__ = 1 A__ = True for v in tree[start]: if v not in visited: ret += dfs(__UpperCamelCase ) if ret % 2 == 0: cuts.append(__UpperCamelCase ) return ret def A (...
9
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
1
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import require_tensorflow_text, requi...
9
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
9
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ = {'''configuration_deit''': ['''DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DeiTConfig''', '''DeiTOnnxC...
9
from __future__ import annotations from typing import Any def A ( __UpperCamelCase ) -> int: if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [] for token in postfix_notation: if token in operations: A__ , A__ = stack.p...
9
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
9
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
1
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> Tuple: A__ = s.rsplit(__UpperCamelCase , __UpperCamelCase ...
9
from __future__ import annotations from fractions import Fraction def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( __UpperCamelCase ) -> list[str]:...
9
1
import glob import os import random from string import ascii_lowercase, digits import cva SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = 1 # (0 is vertical, 1 is horizontal) def A ( ) -> None: ...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
import pprint import requests SCREAMING_SNAKE_CASE__ = '''https://zenquotes.io/api''' def A ( ) -> list: return requests.get(API_ENDPOINT_URL + '/today' ).json() def A ( ) -> list: return requests.get(API_ENDPOINT_URL + '/random' ).json() if __name__ == "...
9
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
1
def A ( ) -> int: return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(__UpperCamelCase , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f'{solution() = }')
9
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
1
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass cla...
9
def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(__UpperCamelCase , exponent // 2 , __UpperCamelCase ) % modulo_value return (x * x) % modul...
9
1
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
1
import argparse import os import torch from transformers.utils import WEIGHTS_NAME SCREAMING_SNAKE_CASE__ = ['''small''', '''medium''', '''large'''] SCREAMING_SNAKE_CASE__ = '''lm_head.decoder.weight''' SCREAMING_SNAKE_CASE__ = '''lm_head.weight''' def A ( __UpperCamelCase , ...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase_ ) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" A__ : str ...
9
def A ( __UpperCamelCase , __UpperCamelCase ) -> Optional[int]: A__ = 0 A__ = len(__UpperCamelCase ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: if sorted_collec...
9
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE__ = {'''processing_layoutxlm''': ['''LayoutXLMProcessor''']} tr...
9
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *_snake_cas...
9
1
from manim import * class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def _a ( self : Union[str, Any] ): """simple docstring""" A__ = Rectangle(height=0.5 , width=0.5 ) A__ = Rectangle(hei...
9
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
9
1
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # noqa F401 ...
9
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
9
1
from __future__ import annotations def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , ) -> tuple[str, float]: if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('You cannot supply more or less than 2 values' ) elif stress <...
9
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
9
1
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFo...
9
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, BertTokenizer, BlipImageP...
9
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE__ = '''docs/source/en/_toctree.yml''' def A ( __UpperCamelCase ) -> Optional[Any]: A__ = defaultdict(__UpperCamelCase ) for doc in model_doc: counts[doc["local"]] += 1 A__ ...
9
1
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem SCREAMING_SNAKE_CASE__ = importlib.util.find_spec('''s3fs''') is not None if _has_safs: from .safilesystem impo...
9
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
9
1
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = {'''vocab_file''': '''vocab.txt'''}...
9
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A ( __UpperCamelCase ) -> Op...
9
1
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets SCREAMING_SNAKE_CASE__ = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, authors={Xu, ...
9
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
9
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" A__ : Optional[Any] = "Speech2TextFeatureExtractor" A__ : Optional[Any] = "S...
9
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
1
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
9
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
1
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
9
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
9
1
from math import factorial, radians def A ( __UpperCamelCase , __UpperCamelCase = 18 , __UpperCamelCase = 10 ) -> float: A__ = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radians A__ = radians(__UpperCamelCase ...
9
from __future__ import annotations from typing import Any def A ( __UpperCamelCase ) -> int: if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [] for token in postfix_notation: if token in operations: A__ , A__ = stack.p...
9
1
import heapq as hq import math from collections.abc import Iterator class __lowerCAmelCase : """simple docstring""" def __init__( self : List[Any] , _snake_case : Tuple ): """simple docstring""" A__ = str(id_ ) ...
9
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # See all CANINE models at https://...
9
from __future__ import annotations from fractions import Fraction def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( __UpperCamelCase ) -> list[str]:...
9
1
def A ( __UpperCamelCase ) -> float: return 10 - x * x def A ( __UpperCamelCase , __UpperCamelCase ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(__UpperCamelCase ) * equation(__UpperCamelCase ) >= 0:...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
from ....utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : List[Any] , _snake_case : str , _snake_case : List[Any...
9
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
1
from __future__ import annotations def A ( __UpperCamelCase , __UpperCamelCase ) -> set[str]: A__ , A__ = set(__UpperCamelCase ), [start] while stack: A__ = stack.pop() explored.add(__UpperCamelCase ) # Differences from BFS: # 1)...
9
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
1
from math import ceil def A ( __UpperCamelCase = 1_001 ) -> int: A__ = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): A__ = 2 * i + 1 A__ = 2 * i A__ = total + 4 * odd**2 - 6 * even return total if __name__ == "__mai...
9
def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(__UpperCamelCase , exponent // 2 , __UpperCamelCase ) % modulo_value return (x * x) % modul...
9
1
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logg...
9
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
1
import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup SCREAMING_SNAKE_CASE__ = { '''User-Agent''': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36''' ''' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582''' ...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
def A ( __UpperCamelCase , __UpperCamelCase ) -> Optional[int]: A__ = 0 A__ = len(__UpperCamelCase ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: if sorted_collec...
9
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { '''configuration_electra''': ['''ELECTRA_PRETRAINED_CONFIG_ARCHIVE_...
9
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *_snake_cas...
9
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''], } try: if not is_torch_a...
9
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
9
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/ma...
9
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
9
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available SCREAMING_SNAKE_CASE__ = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: if ...
9
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType, Opti...
9
1
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : List[str] , _snake_case : Optional[int] , _snake_case : ...
9
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFo...
9
1
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResamp...
9
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE__ = '''docs/source/en/_toctree.yml''' def A ( __UpperCamelCase ) -> Optional[Any]: A__ = defaultdict(__UpperCamelCase ) for doc in model_doc: counts[doc["local"]] += 1 A__ ...
9
1
import os 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 logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = {'''v...
9
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
9
1
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamel...
9
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def A ( __UpperCamelCase ) -> Op...
9
1
from ....configuration_utils import PretrainedConfig from ....utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { '''CarlCochet/trajectory-transformer-halfcheetah-medium-v2''': ( '''https://huggingface.co/CarlCochet/trajectory-transforme...
9
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from .....
9
1
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : List[str] , ...
9
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: A__ = OmegaConf.load(__UpperCamelCase ) A__ = torch.load(__Uppe...
9
1
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def A ( __UpperCamelCase ) -> Optional[Any]: A__ = [ 'encoder.version', 'decoder.version', 'model.encoder.version', 'model.decoder.vers...
9
import json import os import torch from diffusers import UNetaDModel os.makedirs('''hub/hopper-medium-v2/unet/hor32''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/unet/hor128''', exist_ok=True) os.makedirs('''hub/hopper-medium-v2/value_function''', exist_ok=True) def A ( __UpperCamelCase ...
9
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
9
1
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path SCREAMING_SNAKE_CASE__ = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) SCREAMING_SNAKE_CASE__ = [ord(letter) for letter in string.ascii_lowercase] SC...
9
from __future__ import annotations from typing import Any def A ( __UpperCamelCase ) -> int: if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [] for token in postfix_notation: if token in operations: A__ , A__ = stack.p...
9
1
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 ...t...
9
from __future__ import annotations def A ( __UpperCamelCase = 4 ) -> list[list[int]]: A__ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def A ( __UpperCamelCase ) ...
9
1
import pickle import numpy as np from matplotlib import pyplot as plt class __lowerCAmelCase : """simple docstring""" def __init__( self : int , _snake_case : Optional[Any] , _snake_case : Tuple , _snake_case : int ...
9
from __future__ import annotations from fractions import Fraction def A ( __UpperCamelCase , __UpperCamelCase ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( __UpperCamelCase ) -> list[str]:...
9
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.model...
9
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
1
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, t...
9
SCREAMING_SNAKE_CASE__ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' SCREAMING_SNAKE_CASE__ = ...
9
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" @staticmethod @abstractmethod def _a ( _snake_case : ArgumentParser ): """simple docstring""" ...
9
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
9
1
import os import string import sys SCREAMING_SNAKE_CASE__ = 1 << 8 SCREAMING_SNAKE_CASE__ = { '''tab''': ord('''\t'''), '''newline''': ord('''\r'''), '''esc''': 2_7, '''up''': 6_5 + ARROW_KEY_FLAG, '''down''': 6_6 + ARROW_KEY_FLAG, '''right''': 6_7 + ARROW_KEY_FLAG, '''l...
9
def A ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> int: if exponent == 1: return base if exponent % 2 == 0: A__ = _modexpt(__UpperCamelCase , exponent // 2 , __UpperCamelCase ) % modulo_value return (x * x) % modul...
9
1
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFo...
9
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
9
1
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : Dict , *...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1