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 itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import ...
99
import math def a (lowerCAmelCase__ ): 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 are in...
99
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping the # full vocab, merges file...
99
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
1
def a (lowerCAmelCase__ , lowerCAmelCase__ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) __a = (boundary[1] - boundary[0]) / steps __a = boundary[0] __a = boundary[1] __a = make_points(lowerCAmelCase__ , lowerCAmelCase__ , low...
99
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __UpperCAmelCase ( __A ): """simple docstring""" _lowerCamelCase = ["""image_processor""", """tokenizer"""] _lowerCamelCase = ...
99
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 .s...
99
1
import operator as op def a (lowerCAmelCase__ ): __a = [] __a = lambda lowerCAmelCase__ , lowerCAmelCase__ : int(x / y ) # noqa: E731 integer division operation __a = { """^""": op.pow, """*""": op.mul, """/""": div, """+""": op.add...
99
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
99
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class __UpperCAmelCase ( datasets.BeamBasedBuilder ): """simple docstring""" ...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
1
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup SCREAMING_SNAKE_CASE = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2...
99
def a (lowerCAmelCase__ = 1_000_000 ): __a = 1 __a = 1 __a = {1: 1} for inputa in range(2 , lowerCAmelCase__ ): __a = 0 __a = inputa while True: if number in counters: counter += counters[number] break...
99
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device fro...
99
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
1
from collections import deque def a (lowerCAmelCase__ ): __a = len(lowerCAmelCase__ ) __a = deque() __a = [False for _ in range(lowerCAmelCase__ )] __a = [-1 for _ in range(lowerCAmelCase__ )] __a = index_of[:] def strong_connect(lowerCAmelCas...
99
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
1
import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class __UpperCAmelCase ( unittest.TestCase ): """simple ...
99
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE = logging.getLogger...
99
1
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils.dummy_pt...
99
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
1
def a (lowerCAmelCase__ = 10 , lowerCAmelCase__ = 1_000 , lowerCAmelCase__ = True ): assert ( isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) ),...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
1
import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class __UpperCAmelCase ( unittest.TestCase )...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDependency...
99
1
def a (lowerCAmelCase__ ): if not head: return True # split the list to two parts __a , __a = head.next, head while fast and fast.next: __a = fast.next.next __a = slow.next __a = slow.next __a = None # Don't forget here! But forget sti...
99
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5...
99
1
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils ...
99
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerC...
99
1
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def a (lowerCAmelCase__ = True , *lowerCAmelCase__ , **lowerCAmelCase__ ): if not is_tqdm_available(): raise ImportError("""Accelerate's `...
99
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
1
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO, ) SCREAMING_SNAKE_CASE = ...
99
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__nam...
99
1
import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class __UpperC...
99
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
99
1
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator fr...
99
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
99
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig'...
99
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
1
import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( Fla...
99
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'stud...
99
1
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def a (lowerCAmelCase__ ): __a = args.pruning_method __a = args.threshold __a = args.model_name_or_path.rstrip("""/""" ) __...
99
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = ...
99
1
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def a (lowerCAmelCase__ ): __a = [ """encoder.version""", """decoder.version""", """model.encoder.version""", """model.decoder.version...
99
import math def a (lowerCAmelCase__ ): 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 are in...
99
1
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUG...
99
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
1
def a (lowerCAmelCase__ = 1_000 ): __a , __a = 1, 1 __a = 2 while True: __a = 0 __a = fa + fa __a , __a = fa, f index += 1 for _ in str(lowerCAmelCase__ ): i += 1 if i == n: break return index ...
99
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
1
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...t...
99
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 .s...
99
1
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class __UpperCAmelCase ( yaml.SafeLoader ): """simple docstring""" def snake_case_ ( self , __A ): __a = [self.constructed_objects[k...
99
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
99
1
def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: __a = mf_knapsack(i - 1 , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) el...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
1
import collections import importlib.util import os import re from pathlib import Path SCREAMING_SNAKE_CASE = 'src/transformers' # Matches is_xxx_available() SCREAMING_SNAKE_CASE = re.compile(r'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} ...
99
def a (lowerCAmelCase__ = 1_000_000 ): __a = 1 __a = 1 __a = {1: 1} for inputa in range(2 , lowerCAmelCase__ ): __a = 0 __a = inputa while True: if number in counters: counter += counters[number] break...
99
1
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffuser...
99
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
1
import math from collections.abc import Iterator from itertools import takewhile def a (lowerCAmelCase__ ): 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 o...
99
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqLM, ...
99
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE = logging.getLogger...
99
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', 'Dei...
99
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
1
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
1
def a (lowerCAmelCase__ , lowerCAmelCase__ ): if not (isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and isinstance(lowerCAmelCase__ , lowerCAmelCase__ )): raise ValueError("""longest_common_substring() takes two strings for inputs""" ) __a = len(lowerCAmelCase__ ...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDependency...
99
1
def a (lowerCAmelCase__ ): return 10 - x * x def a (lowerCAmelCase__ , lowerCAmelCase__ ): # Bolzano theory in order to find if there is a root between a and b if equation(lowerCAmelCase__ ) * equation(lowerCAmelCase__ ) >= 0: raise ValueError("""Wrong space!""" ) ...
99
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5...
99
1
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline SCREAMING_SNAKE_CASE = logging.ge...
99
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerC...
99
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
99
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
1
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated SCREAMING_SNAKE_CASE = collections.namedtuple('_Dataset...
99
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__nam...
99
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/...
99
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
99
1
from __future__ import annotations from typing import Any class __UpperCAmelCase : """simple docstring""" def __init__( self , __A , __A , __A = 0 ): __a , __a = row, column __a = [[default_value for c in range(__A )] ...
99
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
99
1
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils imp...
99
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
1
def a (lowerCAmelCase__ ): assert column_title.isupper() __a = 0 __a = len(lowerCAmelCase__ ) - 1 __a = 0 while index >= 0: __a = (ord(column_title[index] ) - 64) * pow(26 , lowerCAmelCase__ ) answer += value power += 1 index -= ...
99
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'stud...
99
1
def a (lowerCAmelCase__ ): return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
99
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = ...
99
1
import requests from bsa import BeautifulSoup def a (lowerCAmelCase__ , lowerCAmelCase__ ): __a = BeautifulSoup(requests.get(lowerCAmelCase__ , params=lowerCAmelCase__ ).content , """html.parser""" ) __a = soup.find("""div""" , attrs={"""class""": """gs_ri"""} ...
99
import math def a (lowerCAmelCase__ ): 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 are in...
99
1
def a (lowerCAmelCase__ ): __a = [] if len(lowerCAmelCase__ ) == 1: return [nums.copy()] for _ in range(len(lowerCAmelCase__ ) ): __a = nums.pop(0 ) __a = permute(lowerCAmelCase__ ) for perm in permutations: perm.append(lowerCAmelCase...
99
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__)...
99
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available(): rais...
99
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 .s...
99
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 .s...
99
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
99
1
from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass class __UpperCAmelC...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerC...
99
def a (lowerCAmelCase__ = 1_000_000 ): __a = 1 __a = 1 __a = {1: 1} for inputa in range(2 , lowerCAmelCase__ ): __a = 0 __a = inputa while True: if number in counters: counter += counters[number] break...
99
1
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
99
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: f...
99
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
1
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) SCREAMING_SNAKE_CASE =...
99
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE = logging.getLogger...
99
1
from __future__ import annotations SCREAMING_SNAKE_CASE = list[list[int]] # assigning initial values to the grid SCREAMING_SNAKE_CASE = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], ...
99
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class ...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
1
import argparse import os import re SCREAMING_SNAKE_CASE = 'src/transformers' # Pattern that looks at the indentation in a line. SCREAMING_SNAKE_CASE = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. SCREAMING_SNAKE_CASE = ...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDependency...
99
1
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, ...
99
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5...
99
1
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_t...
99
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerC...
99
1
def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): if len(lowerCAmelCase__ ) != len(lowerCAmelCase__ ): raise ValueError("""The length of profit and weight must be same.""" ) if max_weight <= 0: raise ValueError("""max_weight must greater than zero.""" ) ...
99
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
1
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_card...
99
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__nam...
99
1
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
99
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE = { 'configuration_wav2vec2': ['WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Wa...
99
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
99
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from tra...
99
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
1
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
99
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'stud...
99
1
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_...
99
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = ...
99
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE = logging.get_logger(__name...
99
import math def a (lowerCAmelCase__ ): 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 are in...
99
1
from math import sqrt def a (lowerCAmelCase__ ): 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 num...
99
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
1
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 SCREAMING_SNAKE_...
99
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
1
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def a (lowerCAmelCase__ ): __a = test_file.split(os.path.sep ) if components[0:2] != ["tests", "models"]...
99
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 .s...
99
1
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
99
1
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ 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 diffuse...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
1
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 SCREAMING_SNAKE_CASE = logging.get_logger(__name__) S...
99
def a (lowerCAmelCase__ = 1_000_000 ): __a = 1 __a = 1 __a = {1: 1} for inputa in range(2 , lowerCAmelCase__ ): __a = 0 __a = inputa while True: if number in counters: counter += counters[number] break...
99
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
1
def a (lowerCAmelCase__ , lowerCAmelCase__ ): __a = len(lowerCAmelCase__ ) __a = [] for i in range(len(lowerCAmelCase__ ) - pat_len + 1 ): __a = True for j in range(lowerCAmelCase__ ): if s[i + j] != pattern[j]: __a = False ...
99
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
1
def a (lowerCAmelCase__ ): __a = len(lowerCAmelCase__ ) 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 : len(lowerCAmelCase__ )] # Reverse whole list ...
99
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE = logging.getLogger...
99
1
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = OmegaConf.load(lowerCAmelCase__ ) __a = torch.load(lowerCAmelCase__ , ma...
99
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
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 require...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
1
def a (): __a = [] __a = 1 while len(lowerCAmelCase__ ) < 1E6: constant.append(str(lowerCAmelCase__ ) ) i += 1 __a = """""".join(lowerCAmelCase__ ) return ( int(constant[0] ) * int(constant[9] ) * int(constant[99] ) ...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDependency...
99
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5...
99
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : str = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_available(): ...
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerC...
99
0
from typing import Any class __lowerCamelCase : def __init__( self: Union[str, Any],A_: Any ): '''simple docstring''' __UpperCamelCase = data __UpperCamelCase = None class __lowerCamelCase : ...
1
class __UpperCAmelCase : """simple docstring""" def __init__( self , __A ): __a = set_counts __a = max(__A ) __a = len(__A ) __a = [1] * num_sets __a = list(range(__A ) ) def snake_...
99
0
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding fro...
2
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE = logging.get_logger(__nam...
99
0
'''simple docstring''' import os import pytest from attr import dataclass lowerCAmelCase : Dict = 'us-east-1' # defaults region @dataclass class SCREAMING_SNAKE_CASE__ : lowerCAmelCase_ = 42 lowerCAmelCase_ = """arn:aws:iam::558105141721:ro...
3
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
99
0
"""simple docstring""" import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline,...
4
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
99
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/mai...
5
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def a (lowerCAmelCase__ ): ...
99
0
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: int = 600_851_475_143 ): try: SCREAMING_SNAKE_CASE__ = int(UpperCamelCase__ ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to int.""" ) if n <= 0: raise ValueError("""P...
6
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'stud...
99
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) a = { '''configuration_speech_to_text''': ['''SPEECH_TO...
7
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = ...
99
0
'''simple docstring''' def _lowerCAmelCase ( __snake_case : int = 10_00 ) -> int: __A : Tuple = -1 __A : Tuple = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c ...
8
import math def a (lowerCAmelCase__ ): 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 are in...
99
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 ...t...
9
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
0
def _snake_case ( ): return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(__snake_case , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f'{solution() = }')
10
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor SCREAMING_SNAKE_CASE = logging.getLogger(__name__) SCREAMING_SNAKE_CASE ...
99
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase_ = {"tokenization_wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lowercase_ ...
11
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 .s...
99
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.utils i...
12
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
99
0
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Optional[Any] = logging.get_logger(__name__) A__ : Dict = { """huggingface/time-series-transformer-tourism-monthly""": ( ...
13
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'],...
99
0
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 im...
14
def a (lowerCAmelCase__ = 1_000_000 ): __a = 1 __a = 1 __a = {1: 1} for inputa in range(2 , lowerCAmelCase__ ): __a = 0 __a = inputa while True: if number in counters: counter += counters[number] break...
99
0
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar A : Optional[int] = TypeVar('T') class A ( Generic[T] ): '''simple docstring''' def __init__(self : int , _UpperCAmelCase ...
15
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
0
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : Dict = { 'vocab_file': 'vocab.json', ...
16
import comet # From: unbabel-comet import torch import datasets SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE = '\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie...
99
0
import unittest from knapsack import greedy_knapsack as kp class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self : Optional[Any] ): __A : str = [10, 20, 30, 40, 50, 60] __A : str = [2, 4, 6, 8, 10, 12] __A : List[Any] ...
17
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE = logging.getLogger...
99
0
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __a(SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : bool = False ): ...
18
def a (lowerCAmelCase__ ): __a = False while is_sorted is False: # Until all the indices are traversed keep looping __a = True for i in range(0 , len(lowerCAmelCase__ ) - 1 , 2 ): # iterating over all even indices if input_list[i] > input_list[i + 1]: ...
99
0
"""simple docstring""" _a = """ # 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 """ _a =...
19
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: p...
99
0