





import copy

from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging


UpperCAmelCase_   				=  logging.get_logger(__name__)
class       UpperCamelCase_		(	_lowerCamelCase       ):
					lowerCAmelCase_				=						'''hybrid-clip'''
					lowerCAmelCase_				=						True




					def __init__(		self					,    lowerCAmelCase_=512					,    **lowerCAmelCase_	)		->				List[Any]:
										super().__init__(**lowerCAmelCase_	)

										if "text_config" not in kwargs:
															raise ValueError('`text_config` can not be `None`.'	)

										if "vision_config" not in kwargs:
															raise ValueError('`vision_config` can not be `None`.'	)

										_snake_case						=					kwargs.pop('text_config'	)
										_snake_case						=					kwargs.pop('vision_config'	)

										_snake_case						=					text_config.pop('model_type'	)
										_snake_case						=					vision_config.pop('model_type'	)

										from transformers import AutoConfig

										_snake_case						=					AutoConfig.for_model(lowerCAmelCase_					,    **lowerCAmelCase_	)

										if vision_model_type == "clip":
															_snake_case						=					AutoConfig.for_model(lowerCAmelCase_					,    **lowerCAmelCase_	).vision_config
										elif vision_model_type == "clip_vision_model":
															from transformers import CLIPVisionConfig

															_snake_case						=					CLIPVisionConfig(**lowerCAmelCase_	)
										else:
															_snake_case						=					AutoConfig.for_model(lowerCAmelCase_					,    **lowerCAmelCase_	)

										_snake_case						=					projection_dim
										_snake_case						=					1.0




					@classmethod
					def 						lowerCAmelCase      (		cls					,    lowerCAmelCase_					,    lowerCAmelCase_					,    **lowerCAmelCase_	)		->				int:
										return cls(text_config=text_config.to_dict()					,    vision_config=vision_config.to_dict()					,    **lowerCAmelCase_	)






					def 						lowerCAmelCase      (		self	)		->				Optional[Any]:
										_snake_case						=					copy.deepcopy(self.__dict__	)
										_snake_case						=					self.text_config.to_dict()
										_snake_case						=					self.vision_config.to_dict()
										_snake_case						=					self.__class__.model_type
										return output










import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
					import torch
class       UpperCamelCase_		(	unittest.TestCase				,	_lowerCamelCase       ):




					def 						lowerCAmelCase      (		self	)		->				str:
										_snake_case						=					load_tool('speech-to-text'	)
										self.tool.setup()




					def 						lowerCAmelCase      (		self	)		->				Optional[Any]:
										_snake_case						=					self.tool(torch.ones(3000	)	)
										self.assertEqual(lowerCAmelCase_					,    ' you'	)






					def 						lowerCAmelCase      (		self	)		->				Optional[int]:
										_snake_case						=					self.tool(audio=torch.ones(3000	)	)
										self.assertEqual(lowerCAmelCase_					,    ' you'	)



