


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




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Optional[int]										=	'''ZinengTang/tvlt-base'''
       a						:List[str]										=	tempfile.mkdtemp()




 def 	SCREAMING_SNAKE_CASE__    (		self ,  **_lowerCamelCase   ):
       return TvltImageProcessor.from_pretrained(self.checkpoint ,  **_lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self ,  **_lowerCamelCase   ):
       return TvltFeatureExtractor.from_pretrained(self.checkpoint ,  **_lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       shutil.rmtree(self.tmpdirname   )




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Optional[Any]										=	self.get_image_processor()
       a						:List[Any]										=	self.get_feature_extractor()

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

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




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Union[str, Any]										=	self.get_image_processor()
       a						:Union[str, Any]										=	self.get_feature_extractor()

       a						:Optional[Any]										=	TvltProcessor(image_processor=_lowerCamelCase ,  feature_extractor=_lowerCamelCase   )

       a						:List[Any]										=	np.ones([1_2000]   )

       a						:str										=	feature_extractor(_lowerCamelCase ,  return_tensors='''np'''   )
       a						:str										=	processor(audio=_lowerCamelCase ,  return_tensors='''np'''   )

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




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:int										=	self.get_image_processor()
       a						:Dict										=	self.get_feature_extractor()

       a						:List[Any]										=	TvltProcessor(image_processor=_lowerCamelCase ,  feature_extractor=_lowerCamelCase   )

       a						:Dict										=	np.ones([3, 224, 224]   )

       a						:Tuple										=	image_processor(_lowerCamelCase ,  return_tensors='''np'''   )
       a						:Optional[int]										=	processor(images=_lowerCamelCase ,  return_tensors='''np'''   )

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




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Tuple										=	self.get_image_processor()
       a						:Union[str, Any]										=	self.get_feature_extractor()

       a						:List[Any]										=	TvltProcessor(image_processor=_lowerCamelCase ,  feature_extractor=_lowerCamelCase   )

       a						:Optional[int]										=	np.ones([1_2000]   )
       a						:Optional[int]										=	np.ones([3, 224, 224]   )

       a						:Union[str, Any]										=	processor(audio=_lowerCamelCase ,  images=_lowerCamelCase   )

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




 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       a						:Optional[int]										=	self.get_image_processor()
       a						:List[Any]										=	self.get_feature_extractor()

       a						:List[Any]										=	TvltProcessor(image_processor=_lowerCamelCase ,  feature_extractor=_lowerCamelCase   )

       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''' ,  )









from collections import OrderedDict
from typing import List, Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


snake_case    :   Union[str, Any]	    =					logging.get_logger(__name__)

snake_case    :   List[str]	    =					{
    '''google/efficientnet-b7''': '''https://huggingface.co/google/efficientnet-b7/resolve/main/config.json''',
}







class 		_snake_case  (				_snake_case							):
 SCREAMING_SNAKE_CASE__				=	'efficientnet'




 def __init__(		self ,  _lowerCamelCase = 3 ,  _lowerCamelCase = 600 ,  _lowerCamelCase = 2.0 ,  _lowerCamelCase = 3.1 ,  _lowerCamelCase = 8 ,  _lowerCamelCase = [3, 3, 5, 3, 5, 5, 3] ,  _lowerCamelCase = [32, 16, 24, 40, 80, 112, 192] ,  _lowerCamelCase = [16, 24, 40, 80, 112, 192, 320] ,  _lowerCamelCase = [] ,  _lowerCamelCase = [1, 2, 2, 2, 1, 2, 1] ,  _lowerCamelCase = [1, 2, 2, 3, 3, 4, 1] ,  _lowerCamelCase = [1, 6, 6, 6, 6, 6, 6] ,  _lowerCamelCase = 0.25 ,  _lowerCamelCase = "swish" ,  _lowerCamelCase = 2560 ,  _lowerCamelCase = "mean" ,  _lowerCamelCase = 0.02 ,  _lowerCamelCase = 0.001 ,  _lowerCamelCase = 0.99 ,  _lowerCamelCase = 0.5 ,  _lowerCamelCase = 0.2 ,  **_lowerCamelCase ,  ):
       super().__init__(**_lowerCamelCase   )

       a						:Optional[int]										=	num_channels
       a						:List[str]										=	image_size
       a						:int										=	width_coefficient
       a						:Optional[Any]										=	depth_coefficient
       a						:Any										=	depth_divisor
       a						:Any										=	kernel_sizes
       a						:Tuple										=	in_channels
       a						:Union[str, Any]										=	out_channels
       a						:Any										=	depthwise_padding
       a						:Any										=	strides
       a						:Optional[Any]										=	num_block_repeats
       a						:Tuple										=	expand_ratios
       a						:Dict										=	squeeze_expansion_ratio
       a						:int										=	hidden_act
       a						:Dict										=	hidden_dim
       a						:Tuple										=	pooling_type
       a						:Any										=	initializer_range
       a						:Tuple										=	batch_norm_eps
       a						:Optional[int]										=	batch_norm_momentum
       a						:List[Any]										=	dropout_rate
       a						:Optional[int]										=	drop_connect_rate
       a						:Tuple										=	sum(_lowerCamelCase   ) * 4







class 		_snake_case  (				_snake_case							):
 SCREAMING_SNAKE_CASE__				=	version.parse('1.11'							)




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ]   )




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       return 1e-5





