code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { "configuration_table_transformer": [ "TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TableTrans...
308
"""simple docstring""" 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 tra...
308
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ( ...
707
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICATI...
501
0
import warnings from ..trainer import Trainer from ..utils import logging __lowerCamelCase = logging.get_logger(__name__) class _snake_case ( __lowerCamelCase ): """simple docstring""" def __init__( self , a=None , **a ) -> Dict: """s...
317
'''simple docstring''' from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase__ ( __lowerCamelCase ): """simple docstring""" UpperCamelCase__ = '''...
331
0
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def lowerCamelCase_ ( _lowercase , _lowercase , _lowercase = 10**-10 ) -> float: __A : Any = a while True: __A :...
387
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'EleutherAI/gpt-neox-20b': 'https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json', # See all GPTNeoX models at https:/...
387
1
"""simple docstring""" import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTo...
273
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __UpperCAmelCase = TypeVar("KEY") __UpperCAmelCase = TypeVar("VAL") @dataclass(frozen=snake_case , slots=snake_case ) class SCREAMING...
329
0
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers,...
442
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def lowerCAmelCase_ ( UpperCamelCase__ : str ): """simple docstring""" def decorator(UpperCamelCase__ : Tuple ): __lowercase = getattr(UpperCamelCase__ , """han...
442
1
'''simple docstring''' import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) _a : Optional[Any] ...
689
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_...
689
1
'''simple docstring''' import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_t...
712
'''simple docstring''' import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging __A : List[Any] = logging.get_logger(__name__)...
267
0
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __SCREAMING_SNAKE_CASE =False class UpperCamel...
425
"""simple docstring""" from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class UpperCamelCase ( lowercase_ , lowercase_ ): @register_to_config def _...
425
1
'''simple docstring''' # Copyright 2022 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...
717
from __future__ import annotations def lowerCAmelCase_ (lowercase__ : list[int] ) -> bool: '''simple docstring''' return len(set(lowercase__ ) ) == len(lowercase__ ) if __name__ == "__main__": import doctest doctest.testmod()
288
0
'''simple docstring''' 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.d...
288
'''simple docstring''' 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_mode...
288
1
"""simple docstring""" from __future__ import annotations def _UpperCAmelCase ( lowerCamelCase__ ): """simple docstring""" lowerCAmelCase__ = str(lowerCamelCase__ ) return len(lowerCamelCase__ ) == 9 and set(lowerCamelCase__ ) == set("""123456789""" )...
674
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin...
674
1
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def lowercase__ ( __lowercase : str , __lowercase : Union[str, Any] , __lowercase : List[str] , __lowercase : str , ...
399
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_test...
302
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase__ : str = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Sw...
703
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_f...
172
0
import math def _a ( ) -> Tuple: """simple docstring""" lowerCamelCase__ : Dict = input('''Enter message: ''' ) lowerCamelCase__ : List[str] = int(input(f"Enter key [2-{len(A__ ) - 1}]: " ) ) lowerCamelCase__ : List[Any] = input('''Encryption/...
315
import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/facebook/musicgen-small/resolve/main/compression_...
622
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class a_ ( a__ ):...
333
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def UpperCAmelCase_( a__ , a__ ): """simple docstring""" ...
333
1
def _SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case ) -> Tuple: def count_of_possible_combinations(snake_case ) -> int: if target < 0: return 0 if target == 0: return 1 r...
518
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase :list[list[int]] = [] UpperCamelCase :list[int] = [] UpperCamelCase :List[str] = 0 UpperCamelCase ...
658
0
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester fro...
629
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__ : str = { """configuration_distilbert""": [ """...
629
1
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope="""session""" ) def _SCREAMING_SNAKE_CASE ( ) -> i...
108
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : Optional[int] ): """simple docstring""" snake_case_ : L...
480
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def __lo...
702
'''simple docstring''' import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils im...
687
0
'''simple docstring''' import unittest import numpy as np def __a ( lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : np.ndarray | None = None , ): a__ : Union[str, Any] = np.shape...
688
'''simple docstring''' import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @...
688
1
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _a ( _SCREAMING_SNAKE_CASE : Tuple , _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : str , _SCREAMING_SN...
493
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _snake_case : Optional[Any] = { """configuration_rag""": ["""RagConfig"""], """retrieval_rag""": ["""RagRetriever"""], """token...
493
1
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __magic_name__ ( _...
446
from math import factorial, radians def lowercase_ ( __snake_case : float , __snake_case : int = 18 , __snake_case : int = 10 ) -> float: '''simple docstring''' snake_case__ :Optional[int] = angle_in_degrees - ((a...
241
0
from __future__ import annotations def lowerCamelCase__ ( A__ : Optional[Any] , A__ : Union[str, Any] , A__ : Optional[int] , A__ : Optional[Any] ): # noqa: E741 '''simple docstring''' while r - l > 1: __lowerCamelCase ...
718
import os from collections.abc import Iterator def lowerCamelCase__ ( A__ : str = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(A__ ): __lowerCamelCase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] ...
80
0
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint ...
63
def UpperCamelCase( __UpperCamelCase : Any ): if not head: return True # split the list to two parts lowerCAmelCase_ , lowerCAmelCase_ : Any = head.next, head while fast and fast.next: lowerCAmelCase_ : List[Any] = fast.next.next lowerCA...
171
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", """TableTransformerOnnxConfi...
701
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 from accelerate.t...
622
0
from typing import Dict from .base import GenericTensor, Pipeline class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def UpperCamelCase_ ( self : Tuple , lowerCAmelCase : List[Any]=None , lowerCAmelCase : ...
477
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 snake_case ( SCREAM...
477
1
class __snake_case : def __init__( self : List[Any] ) -> str: '''simple docstring''' _lowerCAmelCase : str = {} def SCREAMING_SNAKE_CASE ( self : Dict ) -> None: '''simple docstring''...
196
from __future__ import annotations from collections.abc import Iterator from typing import Any class __snake_case : def __init__( self : List[Any] , _UpperCAmelCase : Any ) -> Dict: '''simple docstring''' _lowerCAmelCase : Any = ...
196
1
"""simple docstring""" from ...processing_utils import ProcessorMixin class _UpperCAmelCase ( __a): __a : List[str] = """WhisperFeatureExtractor""" __a : Optional[Any] = """WhisperTokenizer""" def __init__( self , _A ...
238
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers impor...
238
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : List[str] = logging.get_logger(__name__) _UpperCamelCase : Any = { """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json""", } ...
719
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
341
0
'''simple docstring''' import argparse from collections import defaultdict import yaml __A ='docs/source/en/_toctree.yml' def _UpperCamelCase ( UpperCamelCase__ ): UpperCAmelCase__ : Dict = defaultdict(UpperCamelCase__ ) UpperCAmelCase__ : ...
407
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBe...
407
1
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def _a( UpperCamelCase__ ...
665
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCL...
665
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_roberta''': [''...
83
class __A : def __init__( self : Dict , UpperCAmelCase_ : Any , UpperCAmelCase_ : int ): lowerCAmelCase : Optional[Any] = name lowerCAmelCase : int = val def __str__( self :...
343
0
'''simple docstring''' def _lowerCamelCase ( lowercase : int = 100 ) -> int: _a = 0 _a = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__m...
521
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def _lowerCamelCase ( lowercase : int = 100_0000 , lowercase : int = 10 ) -> int: _a = defaultdict(lowercase ) for outer_width in range(3 , (t_limit...
521
1
"""simple docstring""" from math import isqrt, loga def _lowerCAmelCase ( UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase_...
155
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): if number < 0 or shift_amount < 0: raise ValueError("""both inputs must be positive integers""" ) __SCREAMING_SNAKE_CASE = str(bin(UpperCamelCase_ ) ) binary_number +=...
155
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils im...
710
'''simple docstring''' import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): snake_case_ = JukeboxTokenizer snake_case_ = { ""...
665
0
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 lowercase ( unittest.TestCase ): def lowercase_ ...
233
'''simple docstring''' def UpperCamelCase__ ( __magic_name__ : List[Any] ) -> Tuple: '''simple docstring''' if not head: return True # split the list to two parts snake_case__ , snake_case__ : Dict = head.next, head while fast and fast.next: snake_...
38
0
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common im...
485
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def __lowercase ( _a ): return np.dot(_a , _a ) class _UpperCAmelCase : def __init__( self : int , *, lowercase_ : float = np.inf , ...
485
1
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=snake_case__ ) class __UpperCAmelCase ( snake_case__ ): """simple docstring""" _snake_case :...
505
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import M...
505
1
def lowerCamelCase__ ( _lowerCamelCase = 1000 ) ->int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
592
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() ...
592
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowerCAmelCase : Dict = { "configuration_layoutlmv3": [ "...
509
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __lowerCAmelCase : Any = logging.get_logger(__name__) __lowerCAmelCase : Optional[Any] = { "vocab_file": ...
509
1
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( snake_case ): @staticmethod @abstractmethod def lowerCAmelCase__ ( a : ArgumentParser ): '''simple docstring''' raise...
706
'''simple docstring''' from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import...
640
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokeni...
378
'''simple docstring''' from math import factorial snake_case = {str(digit): factorial(digit) for digit in range(10)} def UpperCAmelCase_ ( lowerCamelCase_ ): """simple docstring""" if not isinstance(lowerCamelCase_ , lowerCamelCase_ ): raise TypeError("Parameter number mu...
378
1
import heapq def SCREAMING_SNAKE_CASE__ ( lowercase ) -> set[int]: snake_case : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works wit...
684
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...
684
1
"""simple docstring""" from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def a__ ( lowerCAmelCase__ ): return getitem, k def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): return setitem, k, v ...
82
"""simple docstring""" 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 ..imag...
82
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Any = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_rag': ['RagTokenizer'], ...
641
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'ti...
641
1
'''simple docstring''' def lowerCamelCase__ ( _A ): a : List[str] = [0 for i in range(len(_SCREAMING_SNAKE_CASE ) )] # initialize interval's left pointer and right pointer a : List[str] = 0, 0 for i in range(1 , len(_SCREAMING_SNAKE_CASE ) ): #...
526
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets lowercase = datasets.logging.get_logger(__name__) lowercase = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
211
0
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 from accelerate.te...
303
from math import ceil def lowercase__( A = 1_0_0_1 ): snake_case__ : Dict = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): snake_case__ : str = 2 * i + 1 snake_case__ : Any = 2 * i snake...
303
1
'''simple docstring''' class __UpperCAmelCase : def __init__( self ): """simple docstring""" _snake_case = {} def lowerCamelCase ( self ): """simple docstring""" print(self.vertex ) for i in self.ve...
495
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless require...
483
0
import logging import os import threading import time try: import warnings except ImportError: __lowerCamelCase : str = None try: import msvcrt except ImportError: __lowerCamelCase : str = None try: import fcntl except ImportError: __lowerCamelCase : List[Any] ...
38
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __lowerCamelCase : Dict = logging.get_logger(__name__) __lo...
38
1
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class...
28
'''simple docstring''' import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher...
372
0
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration __a = 5_0_0_0_0_0 __a , __a = os.path.split(__file__) __a = os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.repl...
409
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) # TODO Update this __a = { 'facebook/esm-1b': 'https://huggingface.co/facebook/esm-1b...
409
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dist...
55
"""simple docstring""" import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import...
391
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", } class a__ ( _lo...
355
'''simple docstring''' import heapq import sys import numpy as np snake_case_ = tuple[int, int] class a__ : def __init__(self : int ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE : str = [] SCREAMING_SNAKE_CASE : Tuple = set() ...
355
1
'''simple docstring''' import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transfo...
525
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCAmelCase = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import ...
525
1
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a = logging.get_logger(__name__) a = { 't5-small': 'https://huggingface.co/t5-small/resolve/main/conf...
529
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a = { 'configuration_owlvit': [ ...
529
1
import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor ...
305
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import A...
401
0
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig 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_configur...
706
def lowerCAmelCase__ ( UpperCamelCase_ : Optional[int] , UpperCamelCase_ : List[str] , UpperCamelCase_ : List[Any] , UpperCamelCase_ : str )-> int: if height >= 1: move_tower(height - 1 , UpperCamelCase_ , UpperCamelCase_ , ...
526
0
def __lowercase( UpperCAmelCase__ = 1000 ): """simple docstring""" lowerCamelCase , lowerCamelCase = 1, 1 lowerCamelCase = 2 while True: lowerCamelCase = 0 lowerCamelCase = fa ...
623
from __future__ import annotations def __lowercase( UpperCAmelCase__ ): """simple docstring""" lowerCamelCase = 2 lowerCamelCase = [] while i * i <= n: if n % i: i += 1 else: ...
623
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from ....
676
import numpy as np def A ( snake_case__ : np.ndarray ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def A ( snake_case__ : np.ndarray ) -> np.ndarray: '''simple docstring''' return vector * sigmoid(s...
676
1
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from tr...
455
"""simple docstring""" import numpy as np def _snake_case ( __snake_case : np.ndarray ): """simple docstring""" return 1 / (1 + np.exp(-vector )) def _snake_case ( __snake_case : np.ndarray ): """simple docstring"""...
88
0
def snake_case__ ( lowerCamelCase_=28123 ): A : Union[str, Any] = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_divs[k *...
423
def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): return x if y == 0 else greatest_common_divisor(lowerCamelCase_ , x % y ) def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): return (x * y) // greatest_common_divisor(lowerCa...
423
1
def _SCREAMING_SNAKE_CASE ( lowercase : int = 10 ): '''simple docstring''' if not isinstance(lowercase , lowercase ) or n < 0: raise ValueError('Invalid input' ) lowerCamelCase_ = 10**n lowerCamelCase_ = 2_84...
70
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def _SCREAMING_SNAKE_CASE ( lowercase : str , lowercase : float | Decimal , lowercase : float = 10**-10 ): '''simple docs...
70
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import Inter...
152
# 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 vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
152
1
A_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def UpperCAmelCase ( )-> None: '''simple docstring''' SCREAMING_SNAKE_CASE_ = input('''Enter message: ''' ) SCREAMING_SNAKE_CASE_ = input('''Enter key [alphanumeric]: ''' ) SCREAMING_SNAKE_CASE_ ...
393
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.default_plan...
393
1
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __snake_case ( pl.LightningModule ): def __init__( self : Any , _snake_case : Any): ...
169
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class __snake_case ( a , a ): ...
169
1
def _lowerCAmelCase ( lowerCAmelCase_ :int = 600_851_475_143 )->int: '''simple docstring''' try: snake_case_ = int(lowerCAmelCase_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if...
283
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE :Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Dict = { '''vocab_file''': '''voca...
283
1
def _UpperCamelCase ( lowercase__ , lowercase__ ): return "\n".join( F'''{number} * {i} = {number * i}''' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=1_0))
710
from heapq import heappop, heappush import numpy as np def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , ): __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : List[Any] = grid.shape __SCREAMING_SNAKE_CASE : Any = [-1, 1, 0, 0] ...
260
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class snake_case__ ( snake_case...
528
"""simple docstring""" import os def _lowerCamelCase( a = "matrix.txt" ): with open(os.path.join(os.path.dirname(a ) , a ) ) as in_file: __a = in_file.read() __a = [[int(a ) for cell in row.split("," )] for row in data.strip().splitlines()] ...
528
1
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : List[str] , _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' def count_of_possible_combinations(_SCREAMING_SNAKE_CASE : ...
701
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, S...
95
0
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : int = 50 ): A__ = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_length ): ...
440
'''simple docstring''' from __future__ import annotations def UpperCamelCase ( _lowerCamelCase : list[int] ): # This function is recursive A__ = len(_lowerCamelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) ...
440
1
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } ...
362
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class a ( __SCREAMING_SNAKE_CASE ): """simple docstrin...
362
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import...
111
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = {name: getattr(transfo...
111
1
'''simple docstring''' import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transforme...
79
'''simple docstring''' import math class UpperCamelCase__ : """simple docstring""" def __init__( self : List[str] , lowerCamelCase_ : Tuple=0 ): # a graph with Node 0,1,...,N-1 '''simple docstring''' SCREAMING_SNAKE_CASE : Any = n SCR...
79
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } class _lowerCAmelC...
93
"""simple docstring""" # 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....
93
1
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class __UpperCAmelCase ( __lowerCAmelCase ): """simple docstring""" def snake_case_ ( self ): return [ {"col_1": 3, "co...
718
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_determinism, ...
209
0
"""simple docstring""" def lowerCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ )-> int: """simple docstring""" return 1 if input_a == input_a else 0 def lowerCamelCase__ ( )-> None: """simple docstring""" ...
554
"""simple docstring""" def lowerCamelCase__ ( UpperCAmelCase_ = 60_08_51_47_51_43 )-> int: """simple docstring""" try: UpperCamelCase = int(UpperCAmelCase_ ) except (TypeError, ValueError): raise TypeError("P...
554
1
'''simple docstring''' import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.pro...
343
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_a...
343
1
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 app...
351
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig 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_conf...
351
1
'''simple docstring''' from __future__ import annotations def A ( _UpperCAmelCase : float ,_UpperCAmelCase : float ,_UpperCAmelCase : float ,) -> tuple: '''simple docstring''' if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: ...
123
'''simple docstring''' def A ( _UpperCAmelCase : int = 1_0 ,_UpperCAmelCase : int = 1_0_0_0 ,_UpperCAmelCase : bool = True ) -> int: '''simple docstring''' assert ( isinstance(_UpperCAmelCase ,_UpperCAmelCase ) and isinstance(_Upp...
123
1
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __UpperCAmelCase = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, required=True, help='Path to the...
600
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __a ( ctypes.Structure ): # _fields is a specific attr expected by ctypes __snake_case : Optional[Any] = [("""size""", ctypes.c_int),...
600
1
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __A(lowerCAmelCase ) -> List[str]: """simple docstring""" if "model" in orig_key: _UpperCamelCase = orig_key.replace("""model.""" , """""" ) if "norm1" in orig_key: _UpperCamelCase ...
202
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, ResNetCo...
202
1
def _SCREAMING_SNAKE_CASE ( __lowercase : Any , __lowercase : int ) -> int: """simple docstring""" return number | (1 << position) def _SCREAMING_SNAKE_CASE ( __lowercase : Any , __lowercase : Optional[int] ) -> int: ...
637
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline UpperCamelCase_ = { 'n_samples': 6_4, 'horizon': 3_2, 'num_inference_steps': 2_0, 'n_guide_steps': 2, # can set to 0 for faster sampling, does not use value network 'scale_grad_by_std': Tr...
132
0
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmb...
720
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 diffusers....
337
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
104
"""simple docstring""" import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2vec-...
104
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: ...
718
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered # since t...
354
0
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational...
107
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : int = logging.get_logger(__name__) a_ : Union[str, Any] = { '''facebook/encodec_24khz''': '''https://hug...
594
0
def __magic_name__( __UpperCAmelCase = 3 , __UpperCAmelCase = 7 , __UpperCAmelCase = 100_0000 ) -> int: '''simple docstring''' _lowerCamelCase = 0 _lowerCamelCase = 1 for current_denominator in range(1 , limit + 1 ): _l...
708
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.model...
638
0
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTok...
598
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelFo...
512
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @r...
717
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, req...
207
0
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowerCAmelCase__ = '\\n\n' lowerCAmelCase__ = '\nPerplexity (PP...
596
'''simple docstring''' lowerCAmelCase__ = 'Alexander Joslin' import operator as op from .stack import Stack def __UpperCAmelCase ( lowerCamelCase_) -> int: UpperCamelCase__ : List[str] = {'*': op.mul, '/': op.truediv, '+': op.add, ...
596
1
'''simple docstring''' import torch from diffusers import StableDiffusionPipeline UpperCAmelCase : int = 'path-to-your-trained-model' UpperCAmelCase : Dict = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('cuda') UpperCAmelCase : Dict = 'A ...
707
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers i...
47
0
"""simple docstring""" import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class UpperCAmelCase_ : @property def _UpperCamelCa...
420
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def lowercase ( a__ : dict , a__ : str , a__ : set , a__ : set , a__ : dict , a__ : dict , a__ : ...
420
1
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import ...
701
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines....
568
0
import itertools import string from collections.abc import Generator, Iterable def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : Iterable[str] ,lowerCAmelCase_ : int ) -> Generator[tuple[str, ...], None, None]: """simple docstring""" SCREAMING_SNAKE_CASE_ : ...
220
import argparse import collections import json import os import re import string import sys import numpy as np __SCREAMING_SNAKE_CASE = re.compile(r'\b(a|an|the)\b', re.UNICODE) __SCREAMING_SNAKE_CASE = None def SCREAMING_SNAKE_CASE__ ( ) -> str: """simple d...
220
1
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from...
718
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _snake_case = logging.get_logger(__name__) class _lowerCAmelCase : """simple docstring""" def _...
170
0
"""simple docstring""" import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormer...
96
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_sco...
415
0
def _lowerCAmelCase ( _lowerCAmelCase ) -> int: '''simple docstring''' __snake_case = abs(_lowerCAmelCase ) __snake_case = 0 while n > 0: res += n % 10 n //= 10 return res def _lowerCAmelCase ( _lowerCAmelCase ) ...
715
class UpperCamelCase: def __init__( self : Any ) -> Any: '''simple docstring''' __snake_case = 0 __snake_case = 0 __snake_case = {} def SCREAMING_SNAKE_CASE_ ( self : Dict , SCREAMING_SN...
473
0
import re from filelock import FileLock try: import nltk lowerCAmelCase_ = True except (ImportError, ModuleNotFoundError): lowerCAmelCase_ = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=True) ...
39
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer sn...
445
0
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def A__ ( __A ): # picklable for multiprocessing '''s...
15
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, ...
15
1