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
import argparse lowerCamelCase__ : int = """docs/source/_static/js/custom.js""" def UpperCamelCase ( lowercase_ ) -> Dict: '''simple docstring''' with open(lowercase_ , encoding="""utf-8""" , newline="""\n""" ) as f: lowercase__ : Optional[int] ...
12
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import...
12
1
import math class UpperCamelCase__ : def __init__(self : Union[str, Any] , snake_case_ : Any=0 ): # a graph with Node 0,1,...,N-1 __a : Optional[Any] = n __a : Tuple = [ [math.inf for j in range(0 , _UpperCam...
715
from manim import * class UpperCamelCase__ ( __lowercase ): def lowerCAmelCase (self : Any ): __a : Dict = Rectangle(height=0.5 , width=0.5 ) __a : Optional[Any] = Rectangle(height=0.46 , width=0.46 ).set_st...
326
0
def a_ ( SCREAMING_SNAKE_CASE__ : Any , SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : Optional[int] , SCREAMING_SNAKE_CASE__ : Any , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : List[str] ): '''simple docstring''' ...
464
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class A ( UpperCamelCase_ ): UpperCamelCase__ : List[str] =(PNDMScheduler,) UpperCamelCase__ : Dict =(('num_inference_steps', 50),) def lowerCamelCase ...
464
1
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArguments
383
import numpy as np class lowerCAmelCase_ : """simple docstring""" def __init__( self :List[str] ): UpperCamelCase__ :List[str] = (0, 0) UpperCamelCase__ :Dict = None UpperCamelCase__ :List[str] = 0 UpperCamelCase__ :...
383
1
def lowerCAmelCase__ ( UpperCamelCase_ : int )-> int: if not isinstance(UpperCamelCase_ , UpperCamelCase_ ): raise TypeError('''only integers accepted as input''' ) else: A__ = str(abs(UpperCamelCase_ ) ) A__ = ...
632
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
632
1
'''simple docstring''' from cva import destroyAllWindows, imread, imshow, waitKey def _lowerCAmelCase ( __magic_name__ : List[str] ) -> Any: # getting number of pixels in the image lowercase , lowercase : str =img.shape[0], img.shape[1] # convert...
88
'''simple docstring''' import mpmath # for roots of unity import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self : Union[str, Any] , UpperCAmelCase__ : List[Any]=None , UpperCAmelCase__ : Optional[Any]=None ): '''simple docstring''' ...
88
1
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def SCREAMING_SNAKE_CASE__ ( ) -> Tuple: A__ , A__ : Union[str, Any] =9, 1_4 # noqa: F841 A__ : List[Any] =[ [0, 1, 4], [0, 7, 8], ...
416
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...
416
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers fr...
116
import os from datetime import datetime as dt from github import Github SCREAMING_SNAKE_CASE_ = [ """good first issue""", """feature request""", """wip""", ] def __lowercase ( ) -> Optional[int]: '''simple docstring''' SCREAMING_S...
116
1
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class a (_lowerCAmelCase , ...
81
from graphs.minimum_spanning_tree_kruskal import kruskal def SCREAMING_SNAKE_CASE ( ) -> str: UpperCamelCase__ : Tuple = 9 UpperCamelCase__ : Optional[int] = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], ...
228
0
import flax.linen as nn import jax import jax.numpy as jnp class UpperCamelCase ( nn.Module ): __UpperCamelCase =42 __UpperCamelCase =jnp.floataa def UpperCamelCase ( self : int ): """simple docstring""" SCREAMING_SNAKE_CASE = nn.Conv( ...
673
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecat...
673
1
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowerCAmelCase_ = TypeVar('''T''') class __lowerCAmelCase ( Generic[T] ): def __init__(self , __magic_name__ , __magic_name__ ) -> None: ''...
60
import string import numpy def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ) -> int: return b if a == 0 else greatest_common_divisor(b % a , UpperCAmelCase_ ) class lowercase_ : __lowerCamelCase = str...
443
0
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def __UpperCAmelCase ( _UpperCAmelCase : Union[str, Any] , _UpperCAmelCase : str ) ->...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' import numpy as np class lowerCAmelCase__ : def __init__( self : Optional[Any] ) -> List[str]: """simple docstring""" lowerCamelCase_ : Union[str, Any] = (0, 0) lowerCamelCase_ : Optional[Any] = None lowerCamelC...
501
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) __lowerCamelCase : List[str] = { """google/canine-s""": """https://huggingface.co/google/canine-s/resol...
501
1
'''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_roberta im...
717
'''simple docstring''' from itertools import permutations def _UpperCamelCase ( UpperCamelCase__ ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False UpperCAmelCase__...
113
0
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowerCAmelCase__ ( a__: List[Any] , a__: List[Any] ) -> Union[str, Any]: '''simple docstring''' ...
618
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_availabl...
618
1
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def _A ( A ,A ) -> Generator[tuple[str, ...], None, None]: lowercase : List[Any] = iter(__SCREAMING_SNAKE_CASE ) while True: lowercase : str = tupl...
701
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowerCAmelCase : Optional[int] = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.w...
425
0
def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ ): UpperCamelCase__ : int = 1 for i in range(1 , num + 1 ): fact *= i return fact def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ ): UpperCamelCase__ : Optional[Any] = 0 ...
285
# limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate...
285
1
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): UpperCAmelCase_ : Optional[Any] = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear"...
710
import requests def UpperCamelCase ( _A : str , _A : str )-> None: """simple docstring""" A__ = {"Content-Type": "application/json"} A__ = requests.post(_A , json={"text": message_body} , headers=_A ) if re...
232
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ :str = logging.get_logger(__name__) a_ :Tuple = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class lowercase ( _UpperCAmelCase ): lowerCamelCase : Tuple = '''ct...
35
'''simple docstring''' import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class snake_case ( pl.LightningModule ): """simple docstring""" def __init...
675
0
'''simple docstring''' import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.mod...
714
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_con...
319
0
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_, snake_case_=None, **snake_case_ ) -> Union[str, Any]: A__ : Optional[Any] =[x.strip() for x in open(snake_case_ ).readlines()] A__ :...
416
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization...
416
1
"""simple docstring""" # Algorithm for the pigeonhole sorting def lowercase (snake_case__ : Union[str, Any] ) -> Dict: '''simple docstring''' lowerCAmelCase = min(snake_case__ ) # min() finds the minimum value lowerCAmelCase = max(snake_case__ ) # max()...
529
"""simple docstring""" 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 a...
529
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = ...
535
"""simple docstring""" UpperCAmelCase = 8.3_144_598 def __magic_name__ ( _lowerCamelCase: float, _lowerCamelCase: float ) -> float: '''simple docstring''' if temperature < 0: raise Exception('''Temperature cannot be less than 0 K''' ) if molar_mass <= 0: raise Exce...
535
1
"""simple docstring""" from collections import defaultdict def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str ,_lowerCamelCase : str ) -> bool: _lowerCAmelCase : List[Any] = first_str.lower().strip() _lowerCAmelCase : Union[str, Any] = second_str.lower().strip() #...
663
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000000 ) -> int: _lowerCAmelCase : List[str] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,_lowerCamelCase ):...
663
1
import itertools import string from collections.abc import Generator, Iterable def _lowercase ( __UpperCamelCase : Optional[Any] , __UpperCamelCase : List[Any] ): snake_case__ = iter(UpperCAmelCase_ ) while True: snake_case__ = tuple(itertools...
214
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transf...
554
0
def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ = len(SCREAMING_SNAKE_CASE ) A_ = len(SCREAMING_SNAKE_CASE ) A_ = ( first_str_length if first_str_length > s...
705
from __future__ import annotations def _lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if len(SCREAMING_SNAKE_CASE ) == 0: return [] A_ ,A_ = min(SCREAMING_SNAKE_CASE ), max(SCREAMING_SNAKE_CASE ) A_ ...
563
0
"""simple docstring""" from manim import * class A__ ( __lowercase): """simple docstring""" def a__ ( self: Optional[Any] )-> int: lowerCamelCase : List[Any] = Rectangle(height=0.5 , width=0.5 ) lowerCamelCase ...
222
"""simple docstring""" from __future__ import annotations def snake_case ( UpperCamelCase__ : list[int] , UpperCamelCase__ : int ) -> list[list[int]]: lowerCamelCase : list[list[int]] = [] lowerCamelCase : list[int] = [] ...
222
1
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def __a ( A__ = 100_0000 , A__ = 10 ) -> int: lowerCAmelCase = defaultdict(A__ ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer_width * outer_w...
708
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if...
159
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, SegformerForSeman...
265
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar lowerCAmelCase__ = TypeVar('''KEY''') lowerCAmelCase__ = TypeVar('''VAL''') @dataclass(frozen=lowerCamelCase__ , slots=lowerCamelCase...
41
0
def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): if b == 0: return 1 if (b % 2) == 0: return actual_power(lowerCamelCase_ , int(b / 2 ) ) * actual_power(lowerCamelCase_ , int(b / 2 ) ) else: return...
423
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
423
1
from __future__ import annotations def A ( _SCREAMING_SNAKE_CASE ) -> None: create_state_space_tree(_SCREAMING_SNAKE_CASE ,[] ,0 ,[0 for i in range(len(_SCREAMING_SNAKE_CASE ) )] ) def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ,_SCREA...
311
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ (lowerCAmelCase__ ): '''simple docstring''' lowerCamelCase_ : Optional[Any] = (KDPM...
311
1
'''simple docstring''' def __lowerCAmelCase ( a_ = 10 , a_ = 22 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[int] = range(1 , a_ ) SCREAMING_SNAKE_CASE : List[Any] = range(1 ...
715
'''simple docstring''' def __lowerCAmelCase ( a_ = 1000 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = 2**power SCREAMING_SNAKE_CASE : Any = str(a_ ) SCREAMING_SNAKE_CASE : int ...
179
0
import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __ve...
491
# 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.0 # # Unless required by appli...
491
1
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowerCAmelCase__( _UpperCAmelCase ): '''simple docstring''' def __init...
702
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPipelineOutp...
381
0
from itertools import permutations def snake_case (UpperCAmelCase__ ) -> bool: if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False UpperCamelCase_: Optional[int] = [7, 1_1...
57
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ......
367
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_numpy, slow, to...
642
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : Optional[Any] = { "google/umt5-small": "https://huggingface.co/google...
642
1
def __magic_name__ ( __a : int , __a : int ): '''simple docstring''' if number < 0 or shift_amount < 0: raise ValueError("""both inputs must be positive integers""" ) UpperCamelCase__ = str(bin(__a ) ) binary_number += "0" * shif...
513
"""simple docstring""" import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup UpperCamelCase__ = { '''User-Agent''': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36''' ''' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari...
227
0
from datetime import datetime import matplotlib.pyplot as plt import torch def __magic_name__ ( lowercase_ ) -> Union[str, Any]: '''simple docstring''' for param in module.parameters(): UpperCamelCase = False def __magic_name__ ( ...
711
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __magic_name__ ( lowercase_ = "isbn/0140328726" ) -> dict: '''simple docstring''' UpperCamelCase = olid.strip().strip("/" ) # Remove le...
414
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regr...
278
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics ...
67
0
"""simple docstring""" import math def UpperCamelCase ( ) ->None: """simple docstring""" a_ = input("Enter message: " ) a_ = int(input(F'''Enter key [2-{len(UpperCAmelCase ) - 1}]: ''' ) ) a_ = input("Encryption/Decryption [e/d]: " ) if m...
708
"""simple docstring""" def UpperCamelCase ( UpperCAmelCase ) ->list: """simple docstring""" a_ = False while is_sorted is False: # Until all the indices are traversed keep looping a_ = True for i in range(0 , len(UpperCAmelCase ) - 1 , 2 ...
210
0
'''simple docstring''' import os import sys import unittest _a : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402...
168
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def _lowercase ( lowerCamelCase__ ) -> int: """simple docstring""" return DownloadCommand(args.model , args.cache_dir , args.force , ...
168
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": _UpperCAmelCase : str = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: "...
188
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, ...
188
1
"""simple docstring""" from __future__ import annotations def a__ ( SCREAMING_SNAKE_CASE : list[float] , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' print(f"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(S...
645
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( lowercase ): """simple docstring""" a : int ="Speech2TextFeatureExtractor" a : int ="Speech...
645
1
"""simple docstring""" import socket def lowerCAmelCase_( ) -> Dict: _lowerCamelCase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) _lowerCamelCase = socket.gethostname() _lowerCamelCase = 1_23_12 sock.connect((host, port) ) ...
623
"""simple docstring""" import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mo...
623
1
def A ( _lowerCamelCase ): '''simple docstring''' return "".join([hex(_lowerCamelCase )[2:].zfill(2 ).upper() for byte in list(_lowerCamelCase )] ) def A ( _lowerCamelCase ): '''simple docstring''' if (len(_lowerCame...
500
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenceClassification, Data...
500
1
import os from distutils.util import strtobool def _lowercase ( lowercase__ , lowercase__ ): '''simple docstring''' for e in env_keys: __lowerCAmelCase : Union[str, Any] = int(os.environ.get(lowercase__ , -1 ) ) if val >= 0: ...
707
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "microsoft/git-base": "https://huggingface.co/microsoft/git-base/resolve/main/config.json", } ...
583
0
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( lowerCamelCase__ : Optional[int] ) -> List[str]: _SCREAMING_SNAKE_CASE : List[str] = o...
572
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __magic_name__ =argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str, required=True, help=''...
415
0
"""simple docstring""" def snake_case (A_ :int = 6_0_0_8_5_1_4_7_5_1_4_3 ): '''simple docstring''' try: a : str = int(A_ ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Para...
118
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def snake_case (A_ :int = 1_0_0_0_0_0_0 , A_ :int = 1_0 ): '''simple docstring''' a : defaultdict = defaultdict(A_ ) for outer_width in range(3 , (t_limit // 4) + 2...
118
1
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def __A ( a_ :np.ndarray) -> np.ndarray: __a , __a , __a : Dict = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.2_9_8_9 * r + 0.5_8_7...
52
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_fl...
139
0
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowercase = get_tests_dir("""fixtures/test_sentencepiece_with_bytefallba...
591
import functools from typing import Any def lowerCamelCase_ ( UpperCamelCase__ : str, UpperCamelCase__ : list[str] ): '''simple docstring''' if not isinstance(UpperCamelCase__, UpperCamelCase__ ) or len(UpperCamelCase__ ) == 0: raise Valu...
591
1
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenc...
13
def _UpperCamelCase ( lowerCAmelCase_ ) ->int: if n == 1 or not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): return 0 elif n == 2: return 1 else: UpperCAmelCase = [0, 1] for i in range(2 , n + 1 ): sequence.append(sequence[i - 1] + s...
377
0
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class _A ( __UpperCAmelCase ): SCREAMING_SNAKE_CA...
716
from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ =logging.get_logger(__name__) __magic_name__ ={ '''facebook/vit-mae-base''': '''https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json''', # See all ViT MAE models at https://h...
469
0
'''simple docstring''' import argparse import copy def A_ ( _lowerCAmelCase : str ): """simple docstring""" _lowerCamelCase : Optional[Any] = {} with open(_lowerCAmelCase ) as f: for line in f: if line.split()[0] not i...
44
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : List[Any] = { 'configuration_mobilebert': [ 'MOBILEBERT_PRET...
44
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResam...
588
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder impor...
588
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def UpperCamelCase_( snake_case__: int = 3 ) -> qiskit.result.counts.Counts: if isinstance(snake_case__ , snake_case__ ): raise TypeError('number of q...
146
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class lowercase ( _UpperCamelCase , unittest....
146
1
from __future__ import annotations import pandas as pd def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : int ): UpperCamelCase_ : List[Any] = [0] * no_of_proce...
703
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : List[str] , _SCREAMING_SNAKE_CASE : Any , _SCREA...
138
0
'''simple docstring''' from __future__ import annotations import math def __lowercase (_lowercase, _lowercase ) -> list: """simple docstring""" if len(_lowercase ) != 2 or len(a[0] ) != 2 or len(_lowercase ) != 2 or len(b[0] ) != 2: raise Exception("""Matrices are not 2x2"""...
150
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def __lowercase (_lowercase, _lowercase, _lowercase, _lowercase, _lowercase, _lowercase ) -> np.ndarray: """simple docstring""" # prepare kernel ...
150
1
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging SCREAMING_SNAKE_CASE_:Any = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): ...
702
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_:Optional[int] = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is_tor...
520
0
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 lowercase ( snake_case__): ""...
593
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch_...
593
1
from statistics import mean import numpy as np def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): a__ = 0 # Number of processes ...
657
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
1
from __future__ import annotations a : Optional[int] = list[tuple[int, int]] a : int = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0...
63
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a : str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailab...
63
1
'''simple docstring''' import warnings from .generation import TFGenerationMixin class lowerCamelCase__( snake_case_ ): # warning at import time warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be removed in Transformer...
339
'''simple docstring''' from __future__ import annotations from collections.abc import Callable snake_case : str = list[list[float | int]] def lowercase__ ( __UpperCamelCase : Matrix , __UpperCamelCase : Matrix ): '''simple docstring''' __lowerc...
339
1
def __lowerCamelCase ( _lowerCAmelCase ) -> list: _UpperCAmelCase = len(_lowerCAmelCase ) for i in range(1 , _lowerCAmelCase ): _UpperCAmelCase = collection[i] _UpperCAmelCase = 0 _UpperCAmelCase = i - 1 while l...
684
import requests __lowerCAmelCase = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def __lowerCamelCase ( _lowerCAmelCase ) -> None: # fetching a list of articles in json format _UpperCAmelCase = requests.get(_NEWS_API + bbc_news_api_key ).json()...
684
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : List[str] = logging.get_logger(__name__) snake_case : Union[str, Any] = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-l...
657
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case__ : List[Any] = { """configuration_perceiver""": ["""PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
402
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig ...
714
lowerCamelCase__ = [ "DownloadConfig", "DownloadManager", "DownloadMode", "StreamingDownloadManager", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
202
0
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _lowercase ( a__ : np.ndarray ) -> np.ndarray: """simple docstring""" return input_array.reshape((input_array.size, 1) ) de...
147
from __future__ import annotations __lowerCAmelCase = [] def _lowercase ( a__ : list[list[int]] , a__ : int , a__ : int ) -> bool: """simple docstring""" for i in range(len(a__ ) ): if board[row][i] == 1: return False for i ...
147
1
"""simple docstring""" import numpy as np def snake_case (A_ :np.array ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def snake_case (A_ :np.array ): '''simple docstring''' return vector * sigmoid(1.702 * vector ) if __name__ == "__ma...
715
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from ut...
118
0
"""simple docstring""" 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 impo...
49
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward f...
226
0
"""simple docstring""" import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig...
708
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, Musi...
404
0
"""simple docstring""" 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...
453
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.toke...
453
1
class a : def __init__( self , _lowerCAmelCase = "" , _lowerCAmelCase = False ): """simple docstring""" __SCREAMING_SNAKE_CASE: dict[str, RadixNode] = {} # A node will be a leaf if the tree contains its word __SCREAMING...
707
from manim import * class a ( __lowercase ): def snake_case_ ( self ): """simple docstring""" __SCREAMING_SNAKE_CASE: str = Rectangle(height=0.5 , width=0.5 ) __SCREAMING_SNAKE_CASE: Any = Rectan...
146
0
'''simple docstring''' import math def a ( lowerCamelCase__ ): '''simple docstring''' A_ : Union[str, Any] = [] A_ : int = 2 A_ : Tuple = int(math.sqrt(lowerCamelCase__ ) ) # Size of every segment A_ : List[str] ...
667
'''simple docstring''' import math lowerCamelCase :int = 1_0 lowerCamelCase :List[Any] = 7 lowerCamelCase :Union[str, Any] = BALLS_PER_COLOUR * NUM_COLOURS def a ( lowerCamelCase__ = 20 ): '''simple docstring''' A_ : ...
667
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : Any = {...
100
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCAmelCase : List[Any] = {"tokenization_bertweet": ["BertweetTokenizer"]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys UpperC...
100
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_t...
59
'''simple docstring''' import argparse import gc import json import os 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 ...
541
0
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( A...
592
import numpy as np def lowerCamelCase__ ( _lowerCamelCase ) ->np.ndarray: return 1 / (1 + np.exp(-vector )) def lowerCamelCase__ ( _lowerCamelCase ) ->np.ndarray: return vector * sigmoid(_lowerCamelCase ) if __name__ == "__main__": import doctest doctest.testmod...
592
1
from math import factorial, pi def a_ ( __magic_name__ , __magic_name__ = 30 ) -> float: """simple docstring""" if not isinstance(__magic_name__ , (int, float) ): raise ValueError('''maclaurin_sin() requires either an int or float for thet...
598
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 a_ ( unittest....
598
1
'''simple docstring''' def _lowerCAmelCase ( _lowerCAmelCase )-> List[str]: '''simple docstring''' __UpperCAmelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" __UpperCAmelCase = """""" __UpperCAmelCase = """""" # append each character + ...
714
'''simple docstring''' import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def _lowerCAmelCase ( _lowerCAmelCase = 3 )-> qiskit.result.counts.Counts: if isinstance(_lowerCAmelCase , _lowerCAmelCase ...
617
0
"""simple docstring""" from abc import ABC, abstractmethod from typing import List, Optional class __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): """simple docstring""" def __init__( self : List[Any] ) -> Union[str, Any]: """simple docstring""" ...
115
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class UpperCamelCase__ : """simple docstring""" def __init__( self , snake_case__ ): '''simple docstring''' _lowerCAmel...
444
0
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> bool: SCREAMING_SNAKE_CASE__ : List[str] = [int(__lowerCAmelCase ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(__lowerCAmelCase ) == 4 and all(0 <= int(__lowerCAmelCase...
717
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class __a (UpperCamelCase_): '''simple docstring''' def _a ( self , _a ) -> Union[str, Any]: """simple docstring""" ...
12
0
"""simple docstring""" import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def A__ ( A__ , A__ , A__ ) -> Any: '''simple docstring''' _UpperCAmelCase ...
426
"""simple docstring""" import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vi...
426
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : int = { "configuration_electra": ["ELECTRA_PRETRAINED_CONFIG...
710
import requests def UpperCamelCase ( _A : str , _A : str )-> None: """simple docstring""" A__ = {"Content-Type": "application/json"} A__ = requests.post(_A , json={"text": message_body} , headers=_A ) if re...
232
0
'''simple docstring''' def __snake_case( _lowerCAmelCase ) -> str: snake_case__ : List[str] = [0] * len(snake_case__ ) snake_case__ : int = [] snake_case__ : Optional[int] = [1] * len(snake_case__ ) for ...
374
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailab...
40
0
"""simple docstring""" import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import ...
256
"""simple docstring""" class _SCREAMING_SNAKE_CASE : def __init__( self , __A , __A ) -> Optional[Any]: lowerCAmelCase_ :Union[str, Any] = name lowerCAmelCase_ :str = val def __str__( self ) -> Di...
256
1
'''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, prepare_image_inputs if i...
173
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
632
0
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class __SCREAMING_SNAKE_CASE ( _lowerCAmelCase ): @staticmethod @abstractmethod def lowercase_ ( __UpperCAmelCase :ArgumentParser ) -> Tuple: ""...
121
"""simple docstring""" import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_si...
121
1
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin A__ = get_tests_dir("""fixtures/spiece.model""") @req...
166
'''simple docstring''' def lowerCamelCase__ ( _A , _A , _A=False ): if isinstance(_A , _A ) and isinstance(_A , _A ): a : Tuple = len(set_a.intersection(_A ) ) if alternative_union: a : Union[str, Any] = len(_A ...
526
0
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderToke...
209
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent SCREAMING_SNAKE_CASE = {'UserAgent': UserAgent().random} def a (lowerCAmelCase__ ): __a = script.contents[0] __a ...
209
1
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. _SCREAMING_SNAKE_CASE = 10 def _snake_case (_snake_case : int , _snake_case : int , ...
181
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTokeni...
181
1
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_...
513
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __snake_case ={ """configuration_efficientformer""": [ """EFFICIENT...
513
1
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _UpperCamelCase ( snake_case__, snake_case__, snake_case__ ) -> Optional[Any]: # In...
382
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig, ) ...
382
1
'''simple docstring''' class a__ : def __init__( self : Optional[Any] , lowerCamelCase_ : int , lowerCamelCase_ : List[str] , lowerCamelCase_ : Union[str, Any] ): a_ : int = name a_ ...
720
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __lowerCamelCase = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', '''K...
478
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ : str = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", ...
461
def UpperCamelCase ( _UpperCAmelCase : str ) -> bool: '''simple docstring''' _lowercase : List[str] = [int(_UpperCAmelCase ) for i in ip_va_address.split("." ) if i.isdigit()] return len(_UpperCAmelCase ) == 4 and all(0 <= int(_UpperCAmelCase ) <= 254 ...
461
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteSchedule...
122
"""simple docstring""" from math import sqrt def __UpperCAmelCase ( __lowerCamelCase = 1_00_00_00 ) -> int: lowercase__ : int = 0 lowercase__ : int = 0 lowercase__ : int while num_cuboids <= limit: max_cuboid_size += 1 ...
122
1
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils impo...
72
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _snake_case ...
340
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __UpperCamelCase ( _A : Dict , _A : Tuple=False ) ->List[str]: """simple docstring""" lowerCamelCase_ =OmegaConf.load(_A ) ...
75
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __A : Union[str, Any] = logging.get_logger(__name__) __A : Optional[Any] = { 'ut/deta': 'https://huggingface.co/ut/deta/resolve/main/config.json', } class _SCRE...
75
1
'''simple docstring''' from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, ...
28
"""simple docstring""" import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_avai...
682
0
"""simple docstring""" import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging UpperCamelCase_ : List[Any] = logging.get_logger(__name__) UpperCamelCase_ : ...
702
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tra...
482
0
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel snake_case__ : List[Any]...
23
"""simple docstring""" def snake_case__ ( _lowerCamelCase ) ->str: """simple docstring""" return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7...
575
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mo...
715
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __a: Optional[Any] = logging.get_logger(__name__) __a: str = { '''google/bit-50''': '''https://...
402
0