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
from __future__ import annotations from decimal import Decimal from numpy import array def _lowercase( __a : list[list[float]] ): a__ =Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x2 matrices if...
20
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Dict = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM...
21
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
124
0
'''simple docstring''' import numpy as np def snake_case_ (UpperCamelCase : np.ndarray , UpperCamelCase : np.ndarray , UpperCamelCase : float = 1e-12 , UpperCamelCase : int = 100 , ): '''simple docstring''' assert np.shape...
22
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
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 _a ( unittest.TestCase ): ...
23
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(snake_case ) , 'Tatoeba dir...
124
0
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _UpperCamelCase (_lowerCamelCase : str , _lowerCamelCase : Un...
24
import math def lowerCAmelCase_ ( _snake_case : int ) -> int: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number ...
124
0
from collections.abc import Generator def lowerCamelCase__ ( ): SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Dict = 0, 1 while True: SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : List[Any] = b, a + b yield b def lowerCamelCase__ ( _a = 1000): SCREAMING_SNAKE...
25
from collections import defaultdict from math import ceil, sqrt def lowerCAmelCase_ ( _snake_case : int = 1000000 , _snake_case : int = 10 ) -> int: '''simple docstring''' __magic_name__ : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 ...
124
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 ....
26
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor snake_case : Optional[int] = ...
124
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCamelCase( un...
27
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModel...
28
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case : Optional[int] = get_logger(__name__) snake_case : Union[str, Any] = R"\n Args:\n input_ids (`jnp.ndarray` ...
124
0
"""simple docstring""" from jiwer import compute_measures import datasets A_ = """\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER and WIL: improved evaluation ...
29
from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( snake_case ): def SCREAMING_SNAKE_CASE ( self , _a=None , _a=None , _a=None , **_a ): if tokenize_kwargs is None: __magic_name__ : Tuple = {} if tr...
124
0
from ..utils import DummyObject, requires_backends class __a( metaclass=_a ): """simple docstring""" lowerCAmelCase = ['''torch''', '''torchsde'''] def __init__( self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE ) -> Union[str, Any]: requires_bac...
30
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
124
0
def UpperCAmelCase_ ( __UpperCAmelCase : int = 50 ) -> int: SCREAMING_SNAKE_CASE_ = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + ...
31
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: __magic_name__ : str = [] __magic_name__ : Optional[Any] = min(len...
124
0
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def A__ ( SCREAMING_SNAKE_CASE_ : Namespace ) -> Optional[int]: """simple docstring""" return ConvertCommand( args.model_type , args.tf_chec...
32
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
124
0
import argparse import os import re import packaging.version lowerCamelCase__ : Union[str, Any] = """examples/""" lowerCamelCase__ : Union[str, Any] = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_...
33
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipe...
124
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.json', # Se...
34
import os import numpy import onnx def lowerCAmelCase_ ( _snake_case : Tuple , _snake_case : int ) -> List[str]: '''simple docstring''' __magic_name__ : Dict = a.name __magic_name__ : Optional[Any] = b.name __magic_name__ : Opti...
124
0
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, re...
35
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determinis...
124
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): i...
36
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 lowerCAmelCase_ ( _snake_case : int , _snake_case : Union[str, Any] ) ...
124
0
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 A__ ( datasets.BeamBasedBuilder ): """simple docstring""" def _UpperCamelCase( self : List[str] ...
37
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 DDIMScheduler, DDPMScheduler...
124
0
'''simple docstring''' import os def UpperCamelCase__ ( ) -> Union[str, Any]: '''simple docstring''' with open(os.path.dirname(__magic_name__ ) + """/grid.txt""" ) as f: snake_case__ : List[str] = [] # noqa: E741 for _ in range(20 ): l.append([...
38
# 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 applicabl...
124
0
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder lowerCAmelCase_ = '''__DUMMY_TRANSFORMERS_USER__''' lowerCAmelCase_ = '''Dummy User''' lowerCAmelCase_ = ''...
39
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__vers...
124
0
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig ...
40
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling f...
124
0
'''simple docstring''' import os import re 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 lowerCAmelCase__ = logging.get_logger(__name__) lowe...
41
import os import sys import unittest snake_case : List[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
124
0
'''simple docstring''' import string from math import logaa def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ) -> int: lowerCamelCase_ = document.translate( str.maketrans('' ,'' ,string.punctuation ) ).replace('\n' ,'' ) lowerCamelCase_ = ...
42
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig',...
43
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
124
0
'''simple docstring''' import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": UpperCAmelCase_ : List[str] = pd.read_csv('sample_data.csv', header=...
44
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
0
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device UpperCamelCase = False class lowerCAmelCase_ ( unittest.TestCase ): "...
45
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(snake_case ) , 'Tatoeba dir...
124
0
"""simple docstring""" 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.trans...
46
import math def lowerCAmelCase_ ( _snake_case : int ) -> int: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number ...
124
0
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_C...
47
from collections import defaultdict from math import ceil, sqrt def lowerCAmelCase_ ( _snake_case : int = 1000000 , _snake_case : int = 10 ) -> int: '''simple docstring''' __magic_name__ : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 ...
124
0
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, ...
48
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor snake_case : Optional[int] = ...
124
0
"""simple docstring""" def lowercase__ ( snake_case_ :List[str] , snake_case_ :Optional[Any] ): return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase__ ( snake_case_ :str , snake_case_ :Dict=0 ): return sorted(s...
49
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...
50
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case : Optional[int] = get_logger(__name__) snake_case : Union[str, Any] = R"\n Args:\n input_ids (`jnp.ndarray` ...
124
0
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('''repo_id''' , ['''canonical_dataset_name''', '''org-name/dataset-name'''] ) @pytest.mark.parametrize('''path''' , ['''filename.csv''', '''filename with blanks.csv'''] ) ...
51
from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( snake_case ): def SCREAMING_SNAKE_CASE ( self , _a=None , _a=None , _a=None , **_a ): if tokenize_kwargs is None: __magic_name__ : Tuple = {} if tr...
124
0
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger A = '''<<<<<<< This should probably be modified because it mentions: '''...
52
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
124
0
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logg...
53
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: __magic_name__ : str = [] __magic_name__ : Optional[Any] = min(len...
124
0
def a__ ( lowercase__ ): '''simple docstring''' UpperCAmelCase_ =int(lowercase__ ) if n_element < 1: UpperCAmelCase_ =ValueError("a should be a positive number" ) raise my_error UpperCAmelCase_ =[1] UpperC...
54
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
124
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE :Tuple = { 'configuration_nezha': ['NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NezhaConfig'], } try: if not is_torch_available():...
55
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipe...
124
0
'''simple docstring''' 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 imp...
56
import os import numpy import onnx def lowerCAmelCase_ ( _snake_case : Tuple , _snake_case : int ) -> List[str]: '''simple docstring''' __magic_name__ : Dict = a.name __magic_name__ : Optional[Any] = b.name __magic_name__ : Opti...
124
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 Confi...
57
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determinis...
124
0
"""simple docstring""" import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_STAR...
58
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 lowerCAmelCase_ ( _snake_case : int , _snake_case : Union[str, Any] ) ...
124
0
def lowerCAmelCase_ ( __a ) -> int: """simple docstring""" lowerCamelCase__: Optional[Any] =[1] lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__: Union[str, Any] =0, 0, 0 lowerCamelCase__: Union[str, Any] =ugly_nums[ia] * 2 lowerCamel...
59
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 DDIMScheduler, DDPMScheduler...
124
0
def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase ) -> str: """simple docstring""" snake_case_ : Any = (boundary[1] - boundary[0]) / steps snake_case_ : List[Any] = boundary[0] snake_case_ : Tuple = ...
60
# 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 applicabl...
124
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'microsoft/focalnet-tiny': 'https:/...
61
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__vers...
124
0
from random import randint from tempfile import TemporaryFile import numpy as np def lowerCamelCase__ ( lowercase , lowercase , lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : str = 0 if start < end: SCREAMING_SNAKE_CASE : int ...
62
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling f...
124
0
def lowerCamelCase__ ( __lowerCamelCase : List[Any] , __lowerCamelCase : Union[str, Any] ): __UpperCAmelCase : Tuple = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( ...
63
import os import sys import unittest snake_case : List[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
124
0
import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
64
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
"""simple docstring""" import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..t...
65
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
124
0
import functools from typing import Any def __magic_name__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> bool: # Validation if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) or len(SCREAMING_SNAKE_CASE ) == 0: raise Value...
66
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
0
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer ...
67
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(snake_case ) , 'Tatoeba dir...
124
0
class _A : """simple docstring""" def __init__( self : Optional[Any] ) -> Optional[Any]: __UpperCAmelCase ={} def _a ( self : str ) -> None: print(self.vertex ) for i in self.vertex: ...
68
import math def lowerCAmelCase_ ( _snake_case : int ) -> int: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number ...
124
0
'''simple docstring''' # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def __UpperCAmelCase ( _UpperCAmelCase : str ) -> Optional[int]: ...
69
from collections import defaultdict from math import ceil, sqrt def lowerCAmelCase_ ( _snake_case : int = 1000000 , _snake_case : int = 10 ) -> int: '''simple docstring''' __magic_name__ : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 ...
124
0
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 imp...
70
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor snake_case : Optional[int] = ...
124
0
'''simple docstring''' import re def a__ ( _SCREAMING_SNAKE_CASE : str ) -> str: """simple docstring""" if len(re.findall("[ATCG]" , _SCREAMING_SNAKE_CASE ) ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("Invalid Strand" ) return dna.tra...
71
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
'''simple docstring''' from collections import Counter from timeit import timeit def UpperCamelCase ( lowercase_ : str = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def Uppe...
72
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case : Optional[int] = get_logger(__name__) snake_case : Union[str, Any] = R"\n Args:\n input_ids (`jnp.ndarray` ...
124
0
import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def lowerCamelCase__ (_UpperCAmel...
73
from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( snake_case ): def SCREAMING_SNAKE_CASE ( self , _a=None , _a=None , _a=None , **_a ): if tokenize_kwargs is None: __magic_name__ : Tuple = {} if tr...
124
0
def a__ ( snake_case ): """simple docstring""" if isinstance(snake_case , snake_case ): raise TypeError('''\'float\' object cannot be interpreted as an integer''' ) if isinstance(snake_case , snake_case ): raise TypeError('''\'str\' object ca...
74
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
124
0
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase_ ( __a ): lowerCAmelCase__ = 'ClapFeatureExtractor' lowerCAmelCase__ = ('RobertaTokenizer', 'RobertaTokenizerFast') ...
75
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: __magic_name__ : str = [] __magic_name__ : Optional[Any] = min(len...
124
0
"""simple docstring""" # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc...
76
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
124
0
"""simple docstring""" import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_co...
77
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipe...
124
0
'''simple docstring''' from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import ...
78
import os import numpy import onnx def lowerCAmelCase_ ( _snake_case : Tuple , _snake_case : int ) -> List[str]: '''simple docstring''' __magic_name__ : Dict = a.name __magic_name__ : Optional[Any] = b.name __magic_name__ : Opti...
124
0
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, ...
79
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determinis...
124
0
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex __UpperCamelCase : str = logging.getLogger(__name__) class __UpperCamelCase : def __init__( self : Union...
80
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 lowerCAmelCase_ ( _snake_case : int , _snake_case : Union[str, Any] ) ...
124
0
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_tokenization_common import T...
81
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 DDIMScheduler, DDPMScheduler...
124
0
"""simple docstring""" import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from ...
82
# 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 applicabl...
124
0
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationCo...
83
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__vers...
124
0
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE = "The quick brown fox jumps over the lazy dog" , ): lowercase = set() # Replace all the whitespace in our sentence lowercase = input_str.replace(' ' , '' ) for alpha in input_str: if "a" <= alpha.lower() <= "z": fr...
84
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling f...
124
0
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_torch_avai...
85
import os import sys import unittest snake_case : List[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
124
0
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(): ...
86
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
87
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
124
0
"""simple docstring""" import mpmath # for roots of unity import numpy as np class lowercase__ : def __init__( self , SCREAMING_SNAKE_CASE=None , SCREAMING_SNAKE_CASE=None) -> Tuple: # Input as list _lowerCamelCase : Any = list(poly_a or [0]...
88
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
0
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_common...
89
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(snake_case ) , 'Tatoeba dir...
124
0
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMSched...
90
import math def lowerCAmelCase_ ( _snake_case : int ) -> int: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number ...
124
0
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSemanti...
91
from collections import defaultdict from math import ceil, sqrt def lowerCAmelCase_ ( _snake_case : int = 1000000 , _snake_case : int = 10 ) -> int: '''simple docstring''' __magic_name__ : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 ...
124
0
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import requ...
92
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor snake_case : Optional[int] = ...
124
0
"""simple docstring""" import collections import os import re from pathlib import Path __A = """src/transformers""" # Matches is_xxx_available() __A = re.compile(R"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} __A = re.compile(R""...
93
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
'''simple docstring''' def lowercase_ ( __A : int , __A : int ) -> str: """simple docstring""" if not isinstance(__A , __A ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(__A , __A ...
94
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case : Optional[int] = get_logger(__name__) snake_case : Union[str, Any] = R"\n Args:\n input_ids (`jnp.ndarray` ...
124
0
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class ...
95
from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( snake_case ): def SCREAMING_SNAKE_CASE ( self , _a=None , _a=None , _a=None , **_a ): if tokenize_kwargs is None: __magic_name__ : Tuple = {} if tr...
124
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
96
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
124
0
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def a ( ...
97
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: __magic_name__ : str = [] __magic_name__ : Optional[Any] = min(len...
124
0
'''simple docstring''' def a__ ( lowercase : int = 10**12 ) -> int: """simple docstring""" _UpperCamelCase = 1 _UpperCamelCase = 0 _UpperCamelCase = 1 _UpperCamelCase = 1 while numerator <...
98
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_te...
124
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'vinvino02/glpn-kitti': 'https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json', # See all...
99
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipe...
124
0
from torch import nn def __snake_case ( lowerCAmelCase_ ) -> Tuple: if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f'''Unsupported acti...
100
import os import numpy import onnx def lowerCAmelCase_ ( _snake_case : Tuple , _snake_case : int ) -> List[str]: '''simple docstring''' __magic_name__ : Dict = a.name __magic_name__ : Optional[Any] = b.name __magic_name__ : Opti...
124
0
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_co...
101
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determinis...
124
0
"""simple docstring""" def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): if index == number_of_items: return 0 UpperCamelCase : Opt...
102
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 lowerCAmelCase_ ( _snake_case : int , _snake_case : Union[str, Any] ) ...
124
0
"""simple docstring""" def snake_case ( lowerCAmelCase_ = 200 ) -> int: _snake_case = [1, 2, 5, 10, 20, 50, 100, 200] _snake_case = [0] * (pence + 1) _snake_case = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(lowerCA...
103
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 DDIMScheduler, DDPMScheduler...
124
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase = { """configuration_...
104
# 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 applicabl...
124
0
import os import re 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 UpperCamelCase__ : Union[str, Any] = logging.get_logger(__name__) UpperCam...
105
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__vers...
124
0
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class lowerCAmelCase__ : A_ : str = field( metadata={'help': 'The output...
106
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling f...
124
0
'''simple docstring''' 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 _UpperCAmelCase : Tuple = {1: (1, 1), 2: (2, 1), 3: (3, 1...
107
import os import sys import unittest snake_case : List[Any] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
124
0
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a: Optional[Any] = namedtuple( '''_TestCommandArgs''', [ ...
108
from __future__ import annotations from typing import Any class _snake_case ( snake_case ): pass class _snake_case : def __init__( self , _a ): __magic_name__ : Any = data __magic_name__ : Node | None = None def __it...
124
0
'''simple docstring''' from __future__ import annotations class __a : def __init__( self : Optional[int] ,lowerCamelCase : list[list[int]] ): '''simple docstring''' __SCREAMING_SNAKE_CASE = TypeError( """Matrices must be formed ...
109
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
124
0
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
692
import requests def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> None: '''simple docstring''' __magic_name__ : Any = {"Content-Type": "application/json"} __magic_name__ : Optional[int] = requests.post(_snake_case , json={"te...
124
0
def A ( _lowercase = 100 ): SCREAMING_SNAKE_CASE : str = set() SCREAMING_SNAKE_CASE : str = 0 SCREAMING_SNAKE_CASE : str = n + 1 # maximum limit for a in range(2 , _snake_case ): fo...
248
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(snake_case ) , 'Tatoeba dir...
124
0
'''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_flax ...
689
import math def lowerCAmelCase_ ( _snake_case : int ) -> int: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) if number ...
124
0
"""simple docstring""" 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 A__ ( unittest.TestCase): """...
222
from collections import defaultdict from math import ceil, sqrt def lowerCAmelCase_ ( _snake_case : int = 1000000 , _snake_case : int = 10 ) -> int: '''simple docstring''' __magic_name__ : defaultdict = defaultdict(_snake_case ) for outer_width in range(3 ...
124
0
'''simple docstring''' import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_c...
150
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor snake_case : Optional[int] = ...
124
0
"""simple docstring""" from sklearn.metrics import recall_score import datasets a_ = "\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives and FN is the f...
480
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness snake_case : int = "\\n@misc{chen2021evaluating,\n title={Evaluating Large Language...
124
0
"""simple docstring""" # 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 ...
289
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger snake_case : Optional[int] = get_logger(__name__) snake_case : Union[str, Any] = R"\n Args:\n input_ids (`jnp.ndarray` ...
124
0
# 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 appli...
332
from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( snake_case ): def SCREAMING_SNAKE_CASE ( self , _a=None , _a=None , _a=None , **_a ): if tokenize_kwargs is None: __magic_name__ : Tuple = {} if tr...
124
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCAmelCase :Union[str, Any] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
251
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
124
0
from math import factorial def _snake_case ( lowerCAmelCase : int = 2_0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... SCREAMING_SNAKE_CASE_ : Tuple ...
216
def lowerCAmelCase_ ( _snake_case : str , _snake_case : str ) -> float: '''simple docstring''' def get_matched_characters(_snake_case : str , _snake_case : str ) -> str: __magic_name__ : str = [] __magic_name__ : Optional[Any] = min(len...
124
0