code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
from 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, ) fro...
639
import doctest from collections import deque import numpy as np class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = [2, 1, 2, -1] __lowercase = [1, 2, 3, 4] ...
639
1
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a : Any = logging.get_logger(__name__) a : Optional[Any] = { '''huggingface/autoformer-tourism-monthly''': '''https://huggingface.co/huggingface/autoformer-...
639
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
1
import os from distutils.util import strtobool def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' for e in env_keys: __lowercase = int(os.environ.get(_UpperCamelCase , -1 ) ) if val >= 0: return val return default ...
639
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
1
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: raise ValueError('''multiplicative_persistence() does not accept...
639
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
639
1
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM, ...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
import math import sys import cva import numpy as np def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowercase = math.sqrt(_UpperCamelCase ) __lowercase = 1 / (sigma * math.sqrt(2 * math.pi )) return cons * np.exp(-((img / sigma) ...
639
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): impo...
639
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
639
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a : List[Any] = { '''configuration_tapas''': ['''TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TapasConfig'''], '''tokenization_tapas''': ['''TapasTokenize...
639
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, ) fro...
639
1
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPA...
639
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __l...
639
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' def A ( self , snake_case_ ) -> List[Any]: '''simple docstring''' ...
639
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
1
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 DPRContextEncoderTokenizer, DP...
639
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Dict = logging.get_logger(__name__) a : Union[str, Any] = { '''junnyu/roformer_chinese_small...
639
from maths.prime_factors import prime_factors def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCamelCase ) ...
639
1
def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' def get_matched_characters(_UpperCamelCase , _UpperCamelCase ) -> str: __lowercase = [] __lowercase = min(len(_stra ) , len(_stra ) ) // 2 for i, l in en...
639
a : Any = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from .f...
639
1
import pickle import numpy as np from matplotlib import pyplot as plt class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_ , snake_case_ , snake_case_=0.2 , ...
639
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
1
from queue import PriorityQueue from typing import Any import numpy as np def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ...
639
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from tran...
639
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a : int = { '''configuration_clip''': [ '''CLIP_PR...
639
a : Any = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared +=...
639
1
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
639
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
639
1
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decoder, DecoderOutput, Encoder...
639
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
639
1
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 ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPo...
639
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
1
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 a : ...
639
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) __lowercase = hex_num[0] == '''-''' if is_negative: __lowercase = hex_num[1:] tr...
639
1
from __future__ import annotations def lowercase_ ( _UpperCamelCase ): '''simple docstring''' create_state_space_tree(_UpperCamelCase , [] , 0 , [0 for i in range(len(_UpperCamelCase ) )] ) def lowercase_ ( _UpperCamelCase , _UpperCamelCase ,...
639
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
639
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : int = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FunnelConfig'''], ...
639
import doctest from collections import deque import numpy as np class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = [2, 1, 2, -1] __lowercase = [1, 2, 3, 4] ...
639
1
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_xlnet import XLNe...
639
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
1
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import logging ...
639
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
1
from ..utils import DummyObject, requires_backends class lowerCamelCase_ ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase = ["torch", "scipy"] def __init__( self , *snake_case_ , **snake_case_ ) -> List[...
639
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
639
1
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.sche...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
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.models...
639
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): impo...
639
1
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start_docstrings_...
639
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
1
def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __lowercase = str(bin(_UpperCamelCase ) )[2:] # remove the leading "0b" __lowercase = str(bin...
639
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, ) fro...
639
1
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py a : int = '''src/transformers''' # This is to make sure the tr...
639
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __l...
639
1
from __future__ import annotations a : int = list[list[int]] # assigning initial values to the grid a : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5...
639
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
1
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py a : int...
639
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
1
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if num <= 0: raise ValueError('''Input must be a positive integer''' ) __lowercase = [True] * (num + 1) __lowercase = 2 while p * p <= num: if primes[p]: for i in range(p * p , nu...
639
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
1
import socket def lowercase_ ( ): '''simple docstring''' __lowercase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) __lowercase = socket.gethostname() __lowercase = 1_23_12 sock.connect((host, port) ) sock.send(B'''Hello server!''' ) w...
639
from maths.prime_factors import prime_factors def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCamelCase ) ...
639
1
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format...
639
a : Any = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from .f...
639
1
import requests a : Optional[Any] = '''''' # <-- Put your OpenWeatherMap appid here! a : List[Any] = '''https://api.openweathermap.org/data/2.5/''' def lowercase_ ( _UpperCamelCase = "Chicago" , _UpperCamelCase = APPID ): '''simple docstring''' r...
639
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
1
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from ...
639
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from tran...
639
1
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py a : int = '''src/transformers''' a : Dict = '''doc...
639
a : Any = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared +=...
639
1
def lowercase_ ( _UpperCamelCase = 4_00_00_00 ): '''simple docstring''' __lowercase = [] __lowercase , __lowercase = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_UpperCamelCase ) __lowercase , __lowercase = b, a + b ret...
639
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
639
1
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available()...
639
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
639
1
import sys import turtle def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , ...
639
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
1
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if len(_UpperCamelCase ) <= 1: return lst __lowercase = 1 while i < len(_UpperCamelCase ): if lst[i - 1] <= lst[i]: i += 1 else: __lowercase , __lowercase = lst[i], lst[i...
639
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) __lowercase = hex_num[0] == '''-''' if is_negative: __lowercase = hex_num[1:] tr...
639
1
from heapq import heappop, heappush import numpy as np def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , ): '''simple docstring''' __lowercase , __lowercase = grid.shape __lowercase = ...
639
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
639
1
from graphs.minimum_spanning_tree_kruskal import kruskal def lowercase_ ( ): '''simple docstring''' __lowercase = 9 __lowercase = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], [2, 3, 7], ...
639
import doctest from collections import deque import numpy as np class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = [2, 1, 2, -1] __lowercase = [1, 2, 3, 4] ...
639
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a : Tuple = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if not is_vision_avail...
639
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
1
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 ...feat...
639
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Tuple = { '''configuration_lxmert''': ['''LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LxmertConfig''']...
639
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
639
1
def lowercase_ ( _UpperCamelCase = 50 ): '''simple docstring''' __lowercase = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ways_number[row_length]...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
639
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): impo...
639
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def lowercase_ ( _UpperCamelCase = 3 ): '''simple docstring''' if isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('''number of qubits ...
639
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean a : Union[str, Any] = 0 a : Dict = [ [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...
639
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, ) fro...
639
1
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.models.wavaveca ...
639
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __l...
639
1
from cva import destroyAllWindows, imread, imshow, waitKey def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase , __lowercase = img.shape[0], img.shape[1] # converting each pixel's color to its negative for i in range(_UpperCamelCase ): for j in ran...
639
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a : Tuple = logging.get_logger(__name__) a : Dict = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } class lowerCamelCase_ ( ...
639
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
1
# 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 ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet impo...
639
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import MvpTokenizer a : Tu...
639
from maths.prime_factors import prime_factors def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCamelCase ) ...
639
1
from __future__ import annotations def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = str(_UpperCamelCase ) return len(_UpperCamelCase ) == 9 and set(_UpperCamelCase ) == set('''123456789''' ) def lowercase_ ( ): '''simple docstring''' for bas...
639
a : Any = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from .f...
639
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging a : Tuple = logging.get_logger(__name__) class ...
639
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
1
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor a : Optional[int] = logging.getLogger(__name__) a : Any = 50 # m...
639
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from tran...
639
1
class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> List[str]: '''simple docstring''' __lowercase = 0 __lowercase = 0 __lowercase = {} def A ( self , snake_case_ ...
639
a : Any = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared +=...
639
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
639
1
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
639
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
639
1
import warnings from ..trainer import Trainer from ..utils import logging a : Optional[int] = logging.get_logger(__name__) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self , snake_case_=None , **sna...
639
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a : Union[str, Any] = { '''configuration_groupvit''': [ '''GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GroupViTConfig''', '''Group...
639
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) __lowercase = hex_num[0] == '''-''' if is_negative: __lowercase = hex_num[1:] tr...
639
1
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' def __init__( self , snake_cas...
639
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
639
1
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
import doctest from collections import deque import numpy as np class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = [2, 1, 2, -1] __lowercase = [1, 2, 3, 4] ...
639
1
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from tran...
639
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : List[Any] = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.j...
639
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
1
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_=2 , snake_case_=3 , snake_case_=6_4 , s...
639
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
639
1
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional im...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
639
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): impo...
639
1
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
639
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
1
from ..utils import DummyObject, requires_backends class lowerCamelCase_ ( metaclass=lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase = ["flax", "transformers"] def __init__( self , *snake_case_ , **snake_case_ ) -> ...
639
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, ) fro...
639
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDCond...
639
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __l...
639
1
import numpy as np def lowercase_ ( _UpperCamelCase ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' return vector * sigmoid(1.702 * vector ) if __name__ == "__main__": import doctest doctest.testmod() ...
639
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
1
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' def A ( self , snake_case_ ) -> float: ...
639
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
1
# Copyright (c) 2021-, NVIDIA CORPORATION. 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...
639
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
1
import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.tr...
639
from maths.prime_factors import prime_factors def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCamelCase ) ...
639
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
639
a : Any = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Audio from .f...
639
1
import qiskit def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowercase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register __lowercase = qiskit.QuantumCircuit(_UpperCamelCase ,...
639
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' ...
639
1
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowercase_ ( _UpperCamelCase , _UpperCamelCase=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: return ".".join(path.split('''.''' )[n_shave_prefix_se...
639
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from tran...
639
1
from __future__ import annotations a : List[Any] = '''#''' class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = {} def A ( self , snak...
639
a : Any = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squared +=...
639
1
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Union[str, Any] = { '''vocab_file''': '''vocab.json''', '''tokeni...
639
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
639
1
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, require_torch_neuroncore, ) from transfor...
639
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
639
1
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class lowerCamelCase_ ( unittest.TestCase ): '''simple docstring''' def A ( self ) -> List[str]: '''simple docstring''' __lowercase...
639
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
1
import inspect import unittest from transformers import RegNetConfig 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_configuration_common import ConfigTester from ...te...
639
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = hex_num.strip() if not hex_num: raise ValueError('''No value was passed to the function''' ) __lowercase = hex_num[0] == '''-''' if is_negative: __lowercase = hex_num[1:] tr...
639
1
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def lowercase_ ( _UpperCamelCase ): '''simple...
639
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
639
1
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also say that t...
639
import doctest from collections import deque import numpy as np class lowerCamelCase_ : '''simple docstring''' def __init__( self ) -> None: '''simple docstring''' __lowercase = [2, 1, 2, -1] __lowercase = [1, 2, 3, 4] ...
639
1
from collections.abc import Sequence from queue import Queue class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_=None , snake_case_=None ) -> Optional[Any]: ...
639
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
1
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingfac...
639
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
1
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration a : Tuple = 500000 a , a : Tuple = os.path.split(__file__) a : Optional[int] = os.path.join(RESULTS_BASEPATH, '''res...
639
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
639
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __UpperCAmelCase ...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase_ : '''simple docstring''' __UpperCAmelCase = None __UpperCAmelCase = False __UpperCAmelCase = F...
639
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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(): impo...
639
1
import pprint import requests a : int = '''https://zenquotes.io/api''' def lowercase_ ( ): '''simple docstring''' return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase_ ( ): '''simple docstring''' return requests.get(API_ENDPOINT_URL +...
639
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
1
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_flax_auto import FlaxAutoModel from transf...
639
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, ) fro...
639
1
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerc...
639
import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a : List[str] = logging.get_logger(__name__) def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __l...
639
1
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate a : List[str] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('''''', '''|''', '''|'''), ...
639
from collections import Counter from timeit import timeit def lowercase_ ( _UpperCamelCase = "" , ): '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def lowercase_ ( _UpperCamelCase = "" ): '''s...
639
1
def lowercase_ ( _UpperCamelCase , _UpperCamelCase = 0 ): '''simple docstring''' __lowercase = length or len(_UpperCamelCase ) __lowercase = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: __lowercase , __lowercase ...
639
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
639
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Dict = { '''google/pix2struct-textcaps-base''': ( '''https://huggingface.co/google...
639
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position a : Dict = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ...
639
1