






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




						"""simple docstring"""




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Dict=	"ZinengTang/tvlt-base"
												lowercase__    :				int=	tempfile.mkdtemp()




						def 		UpperCAmelCase_	(       self	,  **snake_case__      ):
												'''simple docstring'''
												return TvltImageProcessor.from_pretrained(self.checkpoint	,  **snake_case__      )




						def 		UpperCAmelCase_	(       self	,  **snake_case__      ):
												'''simple docstring'''
												return TvltFeatureExtractor.from_pretrained(self.checkpoint	,  **snake_case__      )




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												shutil.rmtree(self.tmpdirname      )




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Optional[Any]=	self.get_image_processor()
												lowercase__    :				Any=	self.get_feature_extractor()

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

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




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Any=	self.get_image_processor()
												lowercase__    :				str=	self.get_feature_extractor()

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

												lowercase__    :				Union[str, Any]=	np.ones([12000]      )

												lowercase__    :				int=	feature_extractor(snake_case__	,  return_tensors="np"      )
												lowercase__    :				Union[str, Any]=	processor(audio=snake_case__	,  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      ):
												'''simple docstring'''
												lowercase__    :				Any=	self.get_image_processor()
												lowercase__    :				List[str]=	self.get_feature_extractor()

												lowercase__    :				Union[str, Any]=	TvltProcessor(image_processor=snake_case__	,  feature_extractor=snake_case__      )

												lowercase__    :				int=	np.ones([3, 224, 224]      )

												lowercase__    :				Tuple=	image_processor(snake_case__	,  return_tensors="np"      )
												lowercase__    :				Dict=	processor(images=snake_case__	,  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      ):
												'''simple docstring'''
												lowercase__    :				Dict=	self.get_image_processor()
												lowercase__    :				Dict=	self.get_feature_extractor()

												lowercase__    :				Dict=	TvltProcessor(image_processor=snake_case__	,  feature_extractor=snake_case__      )

												lowercase__    :				Tuple=	np.ones([12000]      )
												lowercase__    :				str=	np.ones([3, 224, 224]      )

												lowercase__    :				List[str]=	processor(audio=snake_case__	,  images=snake_case__      )

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




						def 		UpperCAmelCase_	(       self      ):
												'''simple docstring'''
												lowercase__    :				Optional[int]=	self.get_image_processor()
												lowercase__    :				Optional[int]=	self.get_feature_extractor()

												lowercase__    :				Union[str, Any]=	TvltProcessor(image_processor=snake_case__	,  feature_extractor=snake_case__      )

												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 typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


a			:    List[str]				 =		{
    """configuration_xlm_roberta_xl""": [
        """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XLMRobertaXLConfig""",
        """XLMRobertaXLOnnxConfig""",
    ],
}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			a			:    List[str]				 =		[
			    """XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """XLMRobertaXLForCausalLM""",
			    """XLMRobertaXLForMaskedLM""",
			    """XLMRobertaXLForMultipleChoice""",
			    """XLMRobertaXLForQuestionAnswering""",
			    """XLMRobertaXLForSequenceClassification""",
			    """XLMRobertaXLForTokenClassification""",
			    """XLMRobertaXLModel""",
			    """XLMRobertaXLPreTrainedModel""",
			]

if TYPE_CHECKING:
			from .configuration_xlm_roberta_xl import (
			    XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
			    XLMRobertaXLConfig,
			    XLMRobertaXLOnnxConfig,
			)

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_xlm_roberta_xl import (
						    XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
						    XLMRobertaXLForCausalLM,
						    XLMRobertaXLForMaskedLM,
						    XLMRobertaXLForMultipleChoice,
						    XLMRobertaXLForQuestionAnswering,
						    XLMRobertaXLForSequenceClassification,
						    XLMRobertaXLForTokenClassification,
						    XLMRobertaXLModel,
						    XLMRobertaXLPreTrainedModel,
						)

else:
			import sys

			a			:    List[str]				 =		_LazyModule(__name__, globals()["""__file__"""], _import_structure)






