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
from __future__ import annotations from collections.abc import Callable snake_case : Optional[Any] = list[list[float | int]] def __lowercase ( __lowerCAmelCase : Matrix , __lowerCAmelCase : Matrix ): a__ = len(__lowerCAmelCase ) ...
702
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Optional[Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if ...
657
0
import functools def __lowercase ( __lowerCAmelCase : str , __lowerCAmelCase : str ): a__ = len(__lowerCAmelCase ) a__ = len(__lowerCAmelCase ) @functools.cache def min_distance(__lowerCAmelCase : int ...
703
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
657
0
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() snake_case : Any = logging.get_logger(__name__) snake_case : int = { '''post_extract_proj''': '''feature_pro...
704
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
657
0
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import c...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
0
# 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...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
def __lowercase ( __lowerCAmelCase : Union[str, Any] , __lowerCAmelCase : int ): print('\nThe shortest path matrix using Floyd Warshall algorithm\n' ) for i in range(__lowerCAmelCase ): for j in range(__lowerCAmelCase ): ...
707
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 - l...
657
0
from ..utils import DummyObject, requires_backends class snake_case_ (metaclass=lowerCamelCase_ ): UpperCAmelCase__ : Optional[Any] = ['''torch''', '''torchsde'''] def __init__( self :Optional[int] ,*__snake_case :Optional[int] ,**__snake_case :Optional[...
708
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: pre...
657
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def __lowercase ( __lowerCAmelCase : str , __lowerCAmelCase : Union[str, Any] , __lowerC...
709
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
657
0
import argparse import os import torch from transformers.utils import WEIGHTS_NAME snake_case : str = ['''small''', '''medium''', '''large'''] snake_case : Tuple = '''lm_head.decoder.weight''' snake_case : Dict = '''lm_head.weight''' def A ( __lowerCAme...
710
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers fr...
711
from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision...
657
0
'''simple docstring''' def __lowercase ( __lowerCAmelCase : str ): return " ".join( ''.join(word[::-1] ) if len(__lowerCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() ...
712
def __lowercase ( __lowerCAmelCase : int = 2_0_0 ): a__ = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] a__ = [0] * (pence + 1) a__ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(__lowerCAmelCase , pence...
657
0
class snake_case_ : def __init__( self :List[Any] ,__snake_case :str = "" ,__snake_case :bool = False ) -> None: # Mapping from the first character of the prefix of the node a__ = {} # A node will be a leaf if the tree contains its wor...
713
from manim import * class snake_case_ (lowerCamelCase_ ): def lowerCamelCase__( self :Optional[Any] ) -> Optional[int]: a__ = Rectangle(height=0.5 ,width=0.5 ) a__ = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) ...
657
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snake_cas...
714
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : List[str] = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETRA...
715
from math import sqrt def __lowercase ( __lowerCAmelCase : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples ...
657
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 a...
716
import unittest from knapsack import greedy_knapsack as kp class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Optional[Any] ) -> Union[str, Any]: a__ = [10, 20, 30, 40, 50, 60] a__ = [2, 4, 6, 8, 10, 12] a__ = 1...
657
0
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging snake_case : str = logging.get_logger(__name__) def __lowercase ( __lowerCAmelCase : List[Any]=None , ...
717
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule,...
657
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_ca...
718
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
0
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_E...
719
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_s...
657
0
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa ...
720
def __lowercase ( __lowerCAmelCase : int ): a__ = generate_pascal_triangle(__lowerCAmelCase ) for row_idx in range(__lowerCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ...
657
0
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration snake_case : Dict = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'''), ('''kernel''', ...
721
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case : str = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', ''...
657
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 a...
700
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if _...
657
0
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() cl...
701
def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): if len(__lowerCAmelCase ) != len(__lowerCAmelCase ): raise ValueError('The length of profit and weight must be same.' ...
657
0
import os def __lowercase ( __lowerCAmelCase : Optional[int] ): a__ = len(grid[0] ) a__ = len(__lowerCAmelCase ) a__ = 0 a__ = 0 a__ = 0 # Check vertically, horizontally, diagonally at the same time (only work...
702
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Optional[Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if ...
657
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 DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbosi...
703
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
657
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : Dict = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''OP...
704
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
657
0
from ..utils import DummyObject, requires_backends class snake_case_ (metaclass=lowerCamelCase_ ): UpperCAmelCase__ : List[str] = ['''speech'''] def __init__( self :Any ,*__snake_case :Dict ,**__snake_case :List[str] ) -> Dict: re...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
0
import os import numpy import onnx def __lowercase ( __lowerCAmelCase : List[Any] , __lowerCAmelCase : Optional[Any] ): a__ = a.name a__ = b.name a__ = '' a__ = '' a__ = a == b a__ = name_a ...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case = logging.get_logger(__name__) snake_case = {name: getattr(transformers, name + '''Fast''') for name in SLOW_TO_FAST_CONVER...
707
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 - l...
657
0
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 loggi...
708
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: pre...
657
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Optional[int] = logging.get_logger(__name__) snake_case : Any = '''▁'''...
709
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
657
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece ...
710
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
0
import unittest import numpy as np from transformers import DistilBertConfig, 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 ...
711
from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision...
657
0
'''simple docstring''' from statistics import mean import numpy as np def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): a__ = 0 ...
712
def __lowercase ( __lowerCAmelCase : int = 2_0_0 ): a__ = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] a__ = [0] * (pence + 1) a__ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(__lowerCAmelCase , pence...
657
0
class snake_case_ : def __init__( self :Union[str, Any] ) -> Union[str, Any]: a__ = {} def lowerCamelCase__( self :List[str] ) -> None: print(self.vertex ) for i in self.vertex: print(__snake_case ,' ...
713
from manim import * class snake_case_ (lowerCamelCase_ ): def lowerCamelCase__( self :Optional[Any] ) -> Optional[int]: a__ = Rectangle(height=0.5 ,width=0.5 ) a__ = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) ...
657
0
import cva import numpy as np class snake_case_ : def __init__( self :Tuple ,__snake_case :float ,__snake_case :int ) -> List[str]: if k in (0.04, 0.06): a__ = k a__ = window_size else: ...
714
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow ...
715
from math import sqrt def __lowercase ( __lowerCAmelCase : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples ...
657
0
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.tes...
716
import unittest from knapsack import greedy_knapsack as kp class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Optional[Any] ) -> Union[str, Any]: a__ = [10, 20, 30, 40, 50, 60] a__ = [2, 4, 6, 8, 10, 12] a__ = 1...
657
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''', '''InstructB...
717
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule,...
657
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets snake_case : Dict = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, authors={Xu, ...
718
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
0
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_tim...
719
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_s...
657
0
def __lowercase ( __lowerCAmelCase : int | float | str ): try: a__ = float(__lowerCAmelCase ) except ValueError: raise ValueError('Please enter a valid number' ) a__ = decimal - int(__lowerCAmelCase ) if fractio...
720
def __lowercase ( __lowerCAmelCase : int ): a__ = generate_pascal_triangle(__lowerCAmelCase ) for row_idx in range(__lowerCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ...
657
0
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from t...
721
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case : str = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', ''...
657
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case : Any = { '''configuration_altclip''': [ '''ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AltCLIPConfig''', '''AltCLIPTe...
700
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if _...
657
0
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Any = logging.get_logger(__name__) snake_case : List[str] = { '''voca...
701
def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): if len(__lowerCAmelCase ) != len(__lowerCAmelCase ): raise ValueError('The length of profit and weight must be same.' ...
657
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 __lowercase ( ...
702
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Optional[Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if ...
657
0
# 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...
703
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
657
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : str = logging.get_logger(__name__) snake_case : Tuple = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json''', '''microsoft/marku...
704
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
657
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : List[str] = logging.get_logger(__name__) snake_case : Union[str, Any] = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-l...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
0
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_environ...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
import itertools import string from collections.abc import Generator, Iterable def __lowercase ( __lowerCAmelCase : Iterable[str] , __lowerCAmelCase : int ): a__ = iter(__lowerCAmelCase ) while True: a__ = tuple(itertool...
707
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 - l...
657
0
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_NA...
708
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: pre...
657
0
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
709
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
657
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from...
710
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
0
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def __lowercase ( __lowerCAmelCase : Any , __lowerCAmelCase : Dict , __lowerCAmelCase : str , __lowerCAmelCase : List[str] ): ...
711
from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision...
657
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin snake_case : Any ...
712
def __lowercase ( __lowerCAmelCase : int = 2_0_0 ): a__ = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] a__ = [0] * (pence + 1) a__ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(__lowerCAmelCase , pence...
657
0
import os from distutils.util import strtobool def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : Optional[int] ): for e in env_keys: a__ = int(os.environ.get(__lowerCAmelCase , -1 ) ) if val >...
713
from manim import * class snake_case_ (lowerCamelCase_ ): def lowerCamelCase__( self :Optional[Any] ) -> Optional[int]: a__ = Rectangle(height=0.5 ,width=0.5 ) a__ = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) ...
657
0
from math import sqrt def __lowercase ( __lowerCAmelCase : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples...
714
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
0
snake_case : Union[str, Any] = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' snake_case : ...
715
from math import sqrt def __lowercase ( __lowerCAmelCase : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples ...
657
0
def __lowercase ( __lowerCAmelCase : int ): if num <= 0: raise ValueError('Input must be a positive integer' ) a__ = [True] * (num + 1) a__ = 2 while p * p <= num: if primes[p]: for i in range(p ...
716
import unittest from knapsack import greedy_knapsack as kp class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Optional[Any] ) -> Union[str, Any]: a__ = [10, 20, 30, 40, 50, 60] a__ = [2, 4, 6, 8, 10, 12] a__ = 1...
657
0
def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): a__ = F'Input value of [number={number}] must be an integer' raise TypeError(__lowerCAmelCase ) if number < 0: ...
717
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule,...
657
0
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 ...
718
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
0
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class snake_case_ (lowerCamelCase_ , unittest.TestCase ): UpperCAmelCase__ : str = ...
719
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_s...
657
0
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY...
720
def __lowercase ( __lowerCAmelCase : int ): a__ = generate_pascal_triangle(__lowerCAmelCase ) for row_idx in range(__lowerCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ...
657
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case : Tuple = { '''configuration_vision_encoder_decoder''': ['''VisionEncoderDecoderConfig''', '''VisionEncoder...
721
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case : str = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', ''...
657
0
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available snake_case : int = logging.getLogger(__name__) @dataclass c...
700
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if _...
657
0
'''simple docstring''' import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, ...
701
def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): if len(__lowerCAmelCase ) != len(__lowerCAmelCase ): raise ValueError('The length of profit and weight must be same.' ...
657
0
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, TrainingArgument...
702
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Optional[Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if ...
657
0
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case : str = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', ''...
703
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
657
0
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig snake_case : List[Any] = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_pytorch''': ...
704
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
657
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case : Optional[Any] = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP'...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
0
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class snake_case_ (lowerCamelCase_ ): @require_torch def lowerCamelCase__( self :Union[str, Any] ) -> L...
707
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 - l...
657
0
def __lowercase ( __lowerCAmelCase : float ): return 1_0 - x * x def __lowercase ( __lowerCAmelCase : float , __lowerCAmelCase : float ): # Bolzano theory in order to find if there is a root between a and b if...
708
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: pre...
657
0
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path snake_case : Any = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa ...
709
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
657
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class snake_cas...
710
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
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 ...
711
from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision...
657
0
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO, ) snake_case ...
712
def __lowercase ( __lowerCAmelCase : int = 2_0_0 ): a__ = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] a__ = [0] * (pence + 1) a__ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(__lowerCAmelCase , pence...
657
0
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
713
from manim import * class snake_case_ (lowerCamelCase_ ): def lowerCamelCase__( self :Optional[Any] ) -> Optional[int]: a__ = Rectangle(height=0.5 ,width=0.5 ) a__ = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) ...
657
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Optional[int] = logging.get_logger(__name__) snake_case : Any = {'''voc...
714
from math import pi def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int ): return 2 * pi * radius * (angle / 3_6_0) if __name__ == "__main__": print(arc_length(90, 10))
657
0
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_u...
715
from math import sqrt def __lowercase ( __lowerCAmelCase : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples ...
657
0
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Dict ) -> Any: a__ = [...
716
import unittest from knapsack import greedy_knapsack as kp class snake_case_ (unittest.TestCase ): def lowerCamelCase__( self :Optional[Any] ) -> Union[str, Any]: a__ = [10, 20, 30, 40, 50, 60] a__ = [2, 4, 6, 8, 10, 12] a__ = 1...
657
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Union[str, Any] = logging.get_logger(__name__) snake_case : List[Any] = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwritten/resolve...
717
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule,...
657
0
# 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...
718
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
0
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py snake_case : Union[str, Any] ...
719
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_s...
657
0
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTes...
720
def __lowercase ( __lowerCAmelCase : int ): a__ = generate_pascal_triangle(__lowerCAmelCase ) for row_idx in range(__lowerCAmelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ...
657
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING snake_case : List[str] = logging.get_logger(__name__) class snake_case_ (lowerCamelCase_ ): UpperCAmelCase__ : Optional[Any] ...
721
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand snake_case : str = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', '''TS KS 5S 9S AC''', ''...
657
0
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
700
def __lowercase ( __lowerCAmelCase : int ): if length <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('Length must be a positive integer.' ) return [n * (2 * n - 1) for n in range(__lowerCAmelCase )] if _...
657
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import (...
701
def __lowercase ( __lowerCAmelCase : list , __lowerCAmelCase : list , __lowerCAmelCase : int ): if len(__lowerCAmelCase ) != len(__lowerCAmelCase ): raise ValueError('The length of profit and weight must be same.' ...
657
0
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDetection from...
702
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Optional[Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if ...
657
0
from maths.prime_factors import prime_factors def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): a__ = F'Input value of [number={number}] must be an integer' raise TypeError(__low...
703
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
657
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : int = logging.get_logger(__name__) snake_case : Dict = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json''...
704
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class snake_case_ (lowerCamelCase_ , lowerCamelCase_ ): UpperCAmelCase__ ...
657
0
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, Auto...
705
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case : Any = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MobileViTConf...
657
0
import math def __lowercase ( __lowerCAmelCase : float , __lowerCAmelCase : float ): return math.pow(__lowerCAmelCase , 2 ) - a def __lowercase ( __lowerCAmelCase : float ): return 2 * x def ...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
from __future__ import annotations import math snake_case = '''2020.9.26''' snake_case = '''xcodz-dot, cclaus, dhruvmanila''' def __lowercase ( __lowerCAmelCase : float , __lowerCAmelCase : float , __lowerCAmelCase : float ...
707
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 - l...
657
0
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class snake_case_ (lowerCamelCase_ , unittest.TestCase ): UpperCA...
708
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: pre...
657
0
import os def __lowercase ( ): with open(os.path.dirname(__lowerCAmelCase ) + '/p022_names.txt' ) as file: a__ = str(file.readlines()[0] ) a__ = names.replace('"' , '' ).split(',' ) names.sort() a__ = 0 ...
709
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configura...
657
0
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import A...
710
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
657
0
from __future__ import annotations import math def __lowercase ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : bool , __lowerCAmelCase : list[int] , __lowerCAmelCase : ...
711
from decimal import Decimal, getcontext from math import ceil, factorial def __lowercase ( __lowerCAmelCase : int ): if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError('Undefined for non-integers' ) elif precision...
657
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : List[str] = logging.get_logger(__name__) snake_case : int = { '''alibaba-damo/mgp-str-base''': '''https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/co...
712
def __lowercase ( __lowerCAmelCase : int = 2_0_0 ): a__ = [1, 2, 5, 1_0, 2_0, 5_0, 1_0_0, 2_0_0] a__ = [0] * (pence + 1) a__ = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(__lowerCAmelCase , pence...
657
0
from sklearn.metrics import fa_score import datasets snake_case : Optional[int] = ''' The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) ''' snake_case : List[Any] = ''' Args: ...
713
from manim import * class snake_case_ (lowerCamelCase_ ): def lowerCamelCase__( self :Optional[Any] ) -> Optional[int]: a__ = Rectangle(height=0.5 ,width=0.5 ) a__ = Rectangle(height=0.46 ,width=0.46 ).set_stroke(width=0 ) ...
657
0