"""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   UpperCAmelCase_			(					unittest.TestCase):


						def 	_UpperCAmelCase (     self							) ->      Tuple:
													lowercase__    :	List[str]     					=			'ZinengTang/tvlt-base'
													lowercase__    :	Optional[int]     					=			tempfile.mkdtemp()


						def 	_UpperCAmelCase (     self	,    **a							) ->      List[str]:
													return TvltImageProcessor.from_pretrained(self.checkpoint	,    **a							)


						def 	_UpperCAmelCase (     self	,    **a							) ->      Optional[int]:
													return TvltFeatureExtractor.from_pretrained(self.checkpoint	,    **a							)


						def 	_UpperCAmelCase (     self							) ->      str:
													shutil.rmtree(self.tmpdirname							)


						def 	_UpperCAmelCase (     self							) ->      Union[str, Any]:
													lowercase__    :	int     					=			self.get_image_processor()
													lowercase__    :	int     					=			self.get_feature_extractor()

													lowercase__    :	Any     					=			TvltProcessor(image_processor=a	,    feature_extractor=a							)
													processor.save_pretrained(self.tmpdirname							)
													lowercase__    :	Optional[Any]     					=			TvltProcessor.from_pretrained(self.tmpdirname							)

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


						def 	_UpperCAmelCase (     self							) ->      int:
													lowercase__    :	str     					=			self.get_image_processor()
													lowercase__    :	Tuple     					=			self.get_feature_extractor()

													lowercase__    :	Any     					=			TvltProcessor(image_processor=a	,    feature_extractor=a							)

													lowercase__    :	Tuple     					=			np.ones([1_2_0_0_0]							)

													lowercase__    :	int     					=			feature_extractor(a	,    return_tensors='np'							)
													lowercase__    :	str     					=			processor(audio=a	,    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							) ->      List[str]:
													lowercase__    :	Optional[int]     					=			self.get_image_processor()
													lowercase__    :	Dict     					=			self.get_feature_extractor()

													lowercase__    :	int     					=			TvltProcessor(image_processor=a	,    feature_extractor=a							)

													lowercase__    :	str     					=			np.ones([3, 2_2_4, 2_2_4]							)

													lowercase__    :	str     					=			image_processor(a	,    return_tensors='np'							)
													lowercase__    :	List[Any]     					=			processor(images=a	,    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							) ->      Optional[Any]:
													lowercase__    :	int     					=			self.get_image_processor()
													lowercase__    :	Dict     					=			self.get_feature_extractor()

													lowercase__    :	Tuple     					=			TvltProcessor(image_processor=a	,    feature_extractor=a							)

													lowercase__    :	Optional[Any]     					=			np.ones([1_2_0_0_0]							)
													lowercase__    :	Dict     					=			np.ones([3, 2_2_4, 2_2_4]							)

													lowercase__    :	Optional[int]     					=			processor(audio=a	,    images=a							)

													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(a							):
																				processor()


						def 	_UpperCAmelCase (     self							) ->      Tuple:
													lowercase__    :	Union[str, Any]     					=			self.get_image_processor()
													lowercase__    :	Optional[int]     					=			self.get_feature_extractor()

													lowercase__    :	Optional[int]     					=			TvltProcessor(image_processor=a	,    feature_extractor=a							)

													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"""





from .glue import GlueDataset, GlueDataTrainingArguments
from .language_modeling import (
    LineByLineTextDataset,
    LineByLineWithRefDataset,
    LineByLineWithSOPTextDataset,
    TextDataset,
    TextDatasetForNextSentencePrediction,
)
from .squad import SquadDataset, SquadDataTrainingArguments

