

"""simple docstring"""



import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import is_speech_available, is_vision_available
from transformers.testing_utils import require_torch


if is_vision_available():
 from transformers import TvltImageProcessor

if is_speech_available():
 from transformers import TvltFeatureExtractor

from transformers import TvltProcessor



@require_torch
class 					a						(       unittest.TestCase				):



    """simple docstring"""



    def 				UpperCamelCase	(     self: List[Any]       ):






         """simple docstring"""


         A__										=  """ZinengTang/tvlt-base"""
         A__										=  tempfile.mkdtemp()

    def 				UpperCamelCase	(     self: str    ,						**UpperCamelCase: Optional[Any]       ):






         """simple docstring"""


         return TvltImageProcessor.from_pretrained(self.checkpoint    ,						**UpperCamelCase       )

    def 				UpperCamelCase	(     self: Tuple    ,						**UpperCamelCase: Optional[Any]       ):






         """simple docstring"""


         return TvltFeatureExtractor.from_pretrained(self.checkpoint    ,						**UpperCamelCase       )

    def 				UpperCamelCase	(     self: Dict       ):






         """simple docstring"""


         shutil.rmtree(self.tmpdirname       )

    def 				UpperCamelCase	(     self: List[Any]       ):






         """simple docstring"""


         A__										=  self.get_image_processor()
         A__										=  self.get_feature_extractor()

         A__										=  TvltProcessor(image_processor=UpperCamelCase    ,						feature_extractor=UpperCamelCase       )
         processor.save_pretrained(self.tmpdirname       )
         A__										=  TvltProcessor.from_pretrained(self.tmpdirname       )

         self.assertIsInstance(processor.feature_extractor    ,						UpperCamelCase       )
         self.assertIsInstance(processor.image_processor    ,						UpperCamelCase       )

    def 				UpperCamelCase	(     self: Tuple       ):






         """simple docstring"""


         A__										=  self.get_image_processor()
         A__										=  self.get_feature_extractor()

         A__										=  TvltProcessor(image_processor=UpperCamelCase    ,						feature_extractor=UpperCamelCase       )

         A__										=  np.ones([1_20_00]       )

         A__										=  feature_extractor(UpperCamelCase    ,						return_tensors="""np"""       )
         A__										=  processor(audio=UpperCamelCase    ,						return_tensors="""np"""       )

         for key in audio_dict.keys():
              self.assertAlmostEqual(audio_dict[key].sum()    ,						input_processor[key].sum()    ,						delta=1e-2       )

    def 				UpperCamelCase	(     self: Optional[Any]       ):






         """simple docstring"""


         A__										=  self.get_image_processor()
         A__										=  self.get_feature_extractor()

         A__										=  TvltProcessor(image_processor=UpperCamelCase    ,						feature_extractor=UpperCamelCase       )

         A__										=  np.ones([3, 2_24, 2_24]       )

         A__										=  image_processor(UpperCamelCase    ,						return_tensors="""np"""       )
         A__										=  processor(images=UpperCamelCase    ,						return_tensors="""np"""       )

         for key in image_dict.keys():
              self.assertAlmostEqual(image_dict[key].sum()    ,						input_processor[key].sum()    ,						delta=1e-2       )

    def 				UpperCamelCase	(     self: List[Any]       ):






         """simple docstring"""


         A__										=  self.get_image_processor()
         A__										=  self.get_feature_extractor()

         A__										=  TvltProcessor(image_processor=UpperCamelCase    ,						feature_extractor=UpperCamelCase       )

         A__										=  np.ones([1_20_00]       )
         A__										=  np.ones([3, 2_24, 2_24]       )

         A__										=  processor(audio=UpperCamelCase    ,						images=UpperCamelCase       )

         self.assertListEqual(list(inputs.keys()       )    ,						["""audio_values""", """audio_mask""", """pixel_values""", """pixel_mask"""]       )

         # test if it raises when no input is passed
         with pytest.raises(UpperCamelCase       ):
              processor()





    def 				UpperCamelCase	(     self: Union[str, Any]       ):






         """simple docstring"""


         A__										=  self.get_image_processor()
         A__										=  self.get_feature_extractor()

         A__										=  TvltProcessor(image_processor=UpperCamelCase    ,						feature_extractor=UpperCamelCase       )

         self.assertListEqual(
             processor.model_input_names    ,						image_processor.model_input_names + feature_extractor.model_input_names    ,						msg="""`processor` and `image_processor`+`feature_extractor` model input names do not match"""    ,						)









"""simple docstring"""



SCREAMING_SNAKE_CASE_					:	str							  =						'0.21.0'

from .accelerator import Accelerator
from .big_modeling import (
    cpu_offload,
    cpu_offload_with_hook,
    disk_offload,
    dispatch_model,
    init_empty_weights,
    init_on_device,
    load_checkpoint_and_dispatch,
)
from .data_loader import skip_first_batches
from .launchers import debug_launcher, notebook_launcher
from .state import PartialState
from .utils import (
    DeepSpeedPlugin,
    DistributedDataParallelKwargs,
    DistributedType,
    FullyShardedDataParallelPlugin,
    GradScalerKwargs,
    InitProcessGroupKwargs,
    find_executable_batch_size,
    infer_auto_device_map,
    is_rich_available,
    load_checkpoint_in_model,
    synchronize_rng_states,
)


if is_rich_available():
 from .utils import rich






