code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
import argparse import os import torch from transformers.utils import WEIGHTS_NAME snake_case__ : Optional[Any] = ["""small""", """medium""", """large"""] snake_case__ : List[str] = """lm_head.decoder.weight""" snake_case__ : Union[str, Any] = """lm_head.weight""" ...
704
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableU...
655
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer snake_case__ : str = logging.get_logger(__name__) snake_case__ : ...
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import SequenceFeatureExtractio...
706
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar snake_case__ : Union[str, Any] = TypeVar("""T""") snake_case__ : Optional[int] = TypeVar("""U""") class _A ( Generic[T, U] ): '''simple docstring''' def...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) __lowercase = str(bin(_SCREAMING_SNAKE_CASE ) )[2:] # remove the leading "0b" __lowercase = str(bin(_SCREAMING_SNAKE_CA...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
from heapq import heappop, heappush import numpy as np def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , ): __lowercase = grid.shape __lowercase = [-1, 1, 0, 0] __lowercase = [0, 0, -1, 1] if allow_dia...
708
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : int _snake_case : TreeNode | None = None _snake_case : TreeNode | None ...
655
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
709
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
655
0
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_...
710
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging snake_...
655
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available snake_case__ : str = { """configuration_tapas""": ["""TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TapasConfig"""], """tokenization_tapas""": ["""TapasTokeni...
711
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
0
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging snake_case__ : str = logging.get_logger(__name__) snake_case__ ...
712
# 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 ...
655
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
713
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
0
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask snake_case__ : Optional[int] = logging.getLogger(__name__) class _A ( _a ): '''simple docstring''' def __init__( ...
714
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
655
0
import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOutput from ...
715
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _A ( ctypes.Structure ): '''simple docstring''' _snake_case : Optional[Any] = [("""size""", ctypes.c_int), ("""visible""", cty...
655
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 if is_torch_available(): import torch if is_vision_availabl...
716
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 snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : List[str] ...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): if length <= 0 or not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(_SCREAMING_SNAKE_CASE )] if __name__ == "__main__": print(hexagonal_nu...
717
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va,...
655
0
import math def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(_SCREAMING_SNAKE_CASE ) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: ret...
718
from __future__ import annotations from typing import Any class _A : '''simple docstring''' def __init__( self : Union[str, Any] , lowerCamelCase : int ): '''simple docstring''' __lowercase = num_of_nodes __lowercase = ...
655
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : Optional[int] = 42 _snake_case : ...
719
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
655
0
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytesse...
720
from __future__ import annotations import bisect def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 , _SCREAMING_SNAKE_CASE = -1 ): if hi < 0: __lowercase = len(_SCREAMING_SNAKE_CASE ) while lo < hi: __lowercase = lo + (hi - lo)...
655
0
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, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, St...
721
import copy 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 from ..auto import CONFIG_MAPPING snake_case__ : int = logging.get_logger(__name...
655
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) class _A ( _lowercase , _lowercase ): '''simple d...
655
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
701
def snake_case_ ( _SCREAMING_SNAKE_CASE ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __lowercase = gray_code_sequence_string(_SCREAMING_SNAKE_CASE ) # # convert th...
655
0
from collections import defaultdict from math import ceil, sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE = 1_0_0_0_0_0_0 , _SCREAMING_SNAKE_CASE = 1_0 ): __lowercase = defaultdict(_SCREAMING_SNAKE_CASE ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer_width * outer_width ...
702
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Reg...
655
0
from __future__ import annotations from typing import Any class _A ( _lowercase ): '''simple docstring''' pass class _A : '''simple docstring''' def __init__( self : Optional[Any] , lowerCamelCase : Any ): ...
703
from ....utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[str] , lowerCamelCase : Any , lowerCamelCase : Dict=None , lower...
655
0
import json import sys def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Dict: with open(_SCREAMING_SNAKE_CASE , encoding="utf-8" ) as f: __lowercase = json.load(_SCREAMING_SNAKE_CASE ) __lowercase = ["<details>", "<summary>Show updated benchmark...
704
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableU...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(_SCREAMING_SNAKE_CASE ) * abs(_SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord import VideoReader if is_t...
706
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar snake_case__ : Union[str, Any] = TypeVar("""T""") snake_case__ : Optional[int] = TypeVar("""U""") class _A ( Generic[T, U] ): '''simple docstring''' def...
655
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel @require_...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import torch.nn as nn from ..pyt...
708
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : int _snake_case : TreeNode | None = None _snake_case : TreeNode | None ...
655
0
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils import...
709
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
655
0
'''simple docstring''' import math import random def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value snake_case__ : Optional[Any] = 0.0_2 def snake_case_ ...
710
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging snake_...
655
0
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import logging ...
711
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
0
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and ...
712
# 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 ...
655
0
from ....configuration_utils import PretrainedConfig from ....utils import logging snake_case__ : Optional[Any] = logging.get_logger(__name__) snake_case__ : int = { """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-base/bl...
713
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
0
import os import jsonlines import numpy as np from tqdm import tqdm snake_case__ : Dict = 20_48 snake_case__ : str = 40_96 snake_case__ : List[str] = 42 snake_case__ : Dict = os.environ.pop("""PROCESS_TRAIN""", """false""") snake_case__ : Option...
714
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
655
0
from math import sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE ): assert isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" __lowercase = True # 0 and 1 are none primes. if number <= 1: __lowercase ...
715
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _A ( ctypes.Structure ): '''simple docstring''' _snake_case : Optional[Any] = [("""size""", ctypes.c_int), ("""visible""", cty...
655
0
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=1_0_2_4 , _SCREAMING_SNAKE_CASE=1_0_2_4 , _SCREAM...
716
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 snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : List[str] ...
655
0
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import os...
717
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va,...
655
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Tuple = logging.get_logger(__name__) snake_case__ : Optional[int] = { """microsoft/unispeech-large-1500h-cv""": ( """https://huggingface.co/m...
718
from __future__ import annotations from typing import Any class _A : '''simple docstring''' def __init__( self : Union[str, Any] , lowerCamelCase : int ): '''simple docstring''' __lowercase = num_of_nodes __lowercase = ...
655
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class _A ( metaclass=_lowercase ): '''simple docstring''' _snake_case : Any = ["""onnx"""] def __init__( self : Union[str, Any] , *lowerCamelCase : Optional[i...
719
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
655
0
import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput snake_case__ : str = """scheduler_config.json""" class _A ( _lowercase ): ...
720
from __future__ import annotations import bisect def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 , _SCREAMING_SNAKE_CASE = -1 ): if hi < 0: __lowercase = len(_SCREAMING_SNAKE_CASE ) while lo < hi: __lowercase = lo + (hi - lo)...
655
0
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import PriorTransformer ...
721
import copy 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 from ..auto import CONFIG_MAPPING snake_case__ : int = logging.get_logger(__name...
655
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : Dict = { """configuration_luke""": ["""LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LukeConfig"""], """tokenization_luke""": ["""Luk...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) class _A ( _lowercase , _lowercase ): '''simple d...
655
0
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase , __lowercase = analyze_text(_SCREAMING_SNAKE_CASE ) __lowercase = list(" " + ascii_lowercase ) ...
701
def snake_case_ ( _SCREAMING_SNAKE_CASE ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __lowercase = gray_code_sequence_string(_SCREAMING_SNAKE_CASE ) # # convert th...
655
0
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import ena...
702
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Reg...
655
0
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=None ): __lowercase = None if token is not None: __lowercase...
703
from ....utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[str] , lowerCamelCase : Any , lowerCamelCase : Dict=None , lower...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ) -> List[Any]: __lowercase = set() # edges = list of graph's edges __lowercase = get_edges(_SCREAMING_SNAKE_CASE ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_node) and add his extremity...
704
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableU...
655
0
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from transf...
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () snake_case__ : Union[str, Any] = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (tra...
706
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar snake_case__ : Union[str, Any] = TypeVar("""T""") snake_case__ : Optional[int] = TypeVar("""U""") class _A ( Generic[T, U] ): '''simple docstring''' def...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=False ): if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): __lowercase = len(set_a.intersection(_SCREAMING_SNAKE_CASE ...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
import argparse import json import subprocess def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): __lowercase = [] __lowercase = ( F"""curl -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer {token}\"""" " https://api.github.com/repos...
708
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : int _snake_case : TreeNode | None = None _snake_case : TreeNode | None ...
655
0
from __future__ import annotations snake_case__ : Tuple = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_S...
709
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
655
0
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record snake_case__ : List[Any] = """\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understa...
710
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging snake_...
655
0
# 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 ...
711
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE = 1_0_0_0_0_0_0 ): __lowercase = set(range(3 , _SCREAMING_SNAKE_CASE , 2 ) ) primes.add(2 ) for p in range(3 , _SCREAMING_SNAKE_CASE , 2 ): if p not in primes: continue primes.difference_update(set(range(p * p , _SCREAMING_SNAKE_CAS...
712
# 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 ...
655
0
from __future__ import annotations def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): __lowercase , __lowercase = position __lowercase = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y - 1, x - 2), (y + 2, x + 1), ...
713
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase = 0 while num > 0: digit_sum += num % 1_0 num //= 1_0 return digit_sum def snake_case_ ( _SCREAMING_SNAKE_CASE = 1_0_0 ): __lowercase = 1 __lowercase = 2 for i in range(2 , max_n + 1 ): __lo...
714
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
655
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) class _A ( _lowercase , _lowercase ): '''simple d...
715
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _A ( ctypes.Structure ): '''simple docstring''' _snake_case : Optional[Any] = [("""size""", ctypes.c_int), ("""visible""", cty...
655
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __low...
716
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 snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : List[str] ...
655
0
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging snake_c...
717
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va,...
655
0
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers c...
718
from __future__ import annotations from typing import Any class _A : '''simple docstring''' def __init__( self : Union[str, Any] , lowerCamelCase : int ): '''simple docstring''' __lowercase = num_of_nodes __lowercase = ...
655
0
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants snake_case__ : List[Any] = Mapping[str, np.ndarray] snake_case__ : Any = Mappin...
719
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
655
0
import os from collections import deque import torch from torch.utils.data import Dataset class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[Any] , lowerCamelCase : Dict="" , lowerCamelCase : int="train" ): '''simpl...
720
from __future__ import annotations import bisect def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 , _SCREAMING_SNAKE_CASE = -1 ): if hi < 0: __lowercase = len(_SCREAMING_SNAKE_CASE ) while lo < hi: __lowercase = lo + (hi - lo)...
655
0
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 snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : List[str] ...
721
import copy 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 from ..auto import CONFIG_MAPPING snake_case__ : int = logging.get_logger(__name...
655
0
'''simple docstring''' from __future__ import annotations import time snake_case__ : Tuple = list[tuple[int, int]] snake_case__ : Optional[Any] = [ [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], ...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) class _A ( _lowercase , _lowercase ): '''simple d...
655
0
import inspect import unittest class _A ( unittest.TestCase ): '''simple docstring''' def _snake_case ( self : List[Any] ): '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: assert False def _sn...
701
def snake_case_ ( _SCREAMING_SNAKE_CASE ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __lowercase = gray_code_sequence_string(_SCREAMING_SNAKE_CASE ) # # convert th...
655
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(): import torch i...
702
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Reg...
655
0
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor snake_case__ : Tuple = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[Any] , *low...
703
from ....utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[str] , lowerCamelCase : Any , lowerCamelCase : Dict=None , lower...
655
0
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytesse...
704
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableU...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): __lowercase = [[] for _ in range(_SCREAMING_SNAKE_CASE )] __lowercase = key - 1 if key <= 0: raise ValueError("Height of grid can't be 0 or negative" ) if key == 1 or len(_SCREAMING_SNAKE_CASE ) <= key: ...
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
from __future__ import annotations def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase = len(_SCREAMING_SNAKE_CASE ) # We need to create solution object to save path. __lowercase = [[0 for _ in range(_SCREAMING_SNAKE_CASE )] for _ in range(_SCREAMING_SNAKE_CASE )] __lo...
706
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar snake_case__ : Union[str, Any] = TypeVar("""T""") snake_case__ : Optional[int] = TypeVar("""U""") class _A ( Generic[T, U] ): '''simple docstring''' def...
655
0
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 require_to...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPipeline, UN...
708
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : int _snake_case : TreeNode | None = None _snake_case : TreeNode | None ...
655
0
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before toke...
709
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
655
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, ) snake_case__ : int = { """configuration_blenderbot""": [ ...
710
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging snake_...
655
0
from collections.abc import Generator from math import sin def snake_case_ ( _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != 3_2: raise ValueError("Input must be of length 32" ) __lowercase = b"" for i in [3, 2, 1, 0]: little_endian += string_aa[8 * i : 8 * i + 8] ret...
711
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError("Input must be an integer" ) if input_num <= 0: raise ValueError("Input must be positive" ) return sum( divisor for divisor in range(1 , input_num // 2 + 1 ...
712
# 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 ...
655
0
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_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/nie...
713
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
0
import numpy as np def snake_case_ ( _SCREAMING_SNAKE_CASE ): return 1 / (1 + np.exp(-vector )) def snake_case_ ( _SCREAMING_SNAKE_CASE ): return vector * sigmoid(_SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest.testmod()
714
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
655
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError("Input series is not valid, valid series - [2, 4, 6]" ) if len(_SCREAMING_SNAKE_CASE ) == 0: raise ValueError("Input list must be a non empty list" ) if len(_SCRE...
715
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _A ( ctypes.Structure ): '''simple docstring''' _snake_case : Optional[Any] = [("""size""", ctypes.c_int), ("""visible""", cty...
655
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : Optional[Any] = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConfig""", """Inst...
716
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 snake_case__ : List[Any] = logging.get_logger(__name__) snake_case__ : List[str] ...
655
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
717
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va,...
655
0
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline snake_case__ : int = argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) parser.add_argument("""--dpm""", a...
718
from __future__ import annotations from typing import Any class _A : '''simple docstring''' def __init__( self : Union[str, Any] , lowerCamelCase : int ): '''simple docstring''' __lowercase = num_of_nodes __lowercase = ...
655
0
'''simple docstring''' import numpy as np import datasets snake_case__ : Union[str, Any] = """ Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euc...
719
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
655
0
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case__ : Any = logging.get_logger(__name__) snake_case__ : Union[str, Any] ...
720
from __future__ import annotations import bisect def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 , _SCREAMING_SNAKE_CASE = -1 ): if hi < 0: __lowercase = len(_SCREAMING_SNAKE_CASE ) while lo < hi: __lowercase = lo + (hi - lo)...
655
0
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is...
721
import copy 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 from ..auto import CONFIG_MAPPING snake_case__ : int = logging.get_logger(__name...
655
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Optional[Any] = logging.get_logger(__name__) snake_case__ : Dict = { """weiweishi/roc-bert-base-zh""": """https://huggingface.co/weiweishi/roc-bert-base-zh...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) class _A ( _lowercase , _lowercase ): '''simple d...
655
0
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
701
def snake_case_ ( _SCREAMING_SNAKE_CASE ): # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence __lowercase = gray_code_sequence_string(_SCREAMING_SNAKE_CASE ) # # convert th...
655
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplin...
702
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Reg...
655
0
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING snake_case__ : List[str] = { """facebook/mask2former-swin-small-coco-instance""": ( """https://huggingfac...
703
from ....utils import logging snake_case__ : List[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : List[str] , lowerCamelCase : Any , lowerCamelCase : Dict=None , lower...
655
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Optional[int] = logging.get_logger(__name__) snake_case__ : Optional[Any] = { """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama/GPTSAN-2.8B...
704
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableU...
655
0
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=7 ): __lowercase = None if token is not None: __lowercase = {"Accept": "application/vnd.github+j...
705
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _A ( _lowercase , _lowercase ): '''simple docstring''' @register_to_config def __init__( self : Optional[Any] , *, ...
655
0
import random from .binary_exp_mod import bin_exp_mod def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE=1_0_0_0 ): if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __lowercase = n - 1 __lowercase = 0 while d % 2 == 0: d /= 2 ...
706
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar snake_case__ : Union[str, Any] = TypeVar("""T""") snake_case__ : Optional[int] = TypeVar("""U""") class _A ( Generic[T, U] ): '''simple docstring''' def...
655
0
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated snake_case__ : Optional[int] = collections.namedtuple("""_Datasets""...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def snake_case_ ( _SCREAM...
708
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _A : '''simple docstring''' _snake_case : int _snake_case : TreeNode | None = None _snake_case : TreeNode | None ...
655
0
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @requi...
709
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowerc...
655
0
'''simple docstring''' def snake_case_ ( _SCREAMING_SNAKE_CASE ): if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise TypeError("Input value must be a 'int' type" ) return bin(_SCREAMING_SNAKE_CASE...
710
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging snake_...
655
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, Da...
711
def snake_case_ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): if len(_SCREAMING_SNAKE_CASE ) != len(_SCREAMING_SNAKE_CASE ): raise ValueError("The length of profit and weight must be same." ) if max_weight <= 0: raise ValueError("max_weight must greater than zer...
655
0
from PIL import Image def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase , __lowercase = image.size __lowercase = 0 __lowercase = image.load() for i in range(_SCREAMING_SNAKE_CASE ): for j in range(_SCREAMING_SNAKE_CASE ): __lowercase = ...
712
# 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 ...
655
0
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class _A ( enum.Enum ): '''simple docstring''' ...
713
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
0
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, ) snake_case__ : Union[str, Any] = { """configuration_al...
714
import numpy as np snake_case__ : Tuple = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ]...
655
0
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class _A : '''simple docstring''' _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [...
715
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _A ( ctypes.Structure ): '''simple docstring''' _snake_case : Optional[Any] = [("""size""", ctypes.c_int), ("""visible""", cty...
655
0