





"""simple docstring"""




import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


UpperCamelCase_           =logging.get_logger(__name__)




class  _a						(      _lowerCAmelCase				):
				UpperCamelCase								=    '''vision-text-dual-encoder'''
				UpperCamelCase								=    True






				def __init__( self		:    Dict, lowerCAmelCase__		:    int=5_1_2, lowerCAmelCase__		:    Optional[int]=2.6_592, **lowerCAmelCase__		:    Union[str, Any]							)	->      Any:




										'''simple docstring'''



										super().__init__(**lowerCAmelCase__							)

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

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

										_UpperCamelCase			:					List[Any]     =    kwargs.pop('''vision_config'''							)
										_UpperCamelCase			:					Optional[int]     =    kwargs.pop('''text_config'''							)

										_UpperCamelCase			:					List[str]     =    vision_config.pop('''model_type'''							)
										_UpperCamelCase			:					Dict     =    text_config.pop('''model_type'''							)

										if vision_model_type == "clip":
																_UpperCamelCase			:					str     =    AutoConfig.for_model(lowerCAmelCase__, **lowerCAmelCase__							).vision_config
										elif vision_model_type == "clip_vision_model":
																_UpperCamelCase			:					Dict     =    CLIPVisionConfig(**lowerCAmelCase__							)
										else:
																_UpperCamelCase			:					Dict     =    AutoConfig.for_model(lowerCAmelCase__, **lowerCAmelCase__							)

										_UpperCamelCase			:					Any     =    AutoConfig.for_model(lowerCAmelCase__, **lowerCAmelCase__							)

										_UpperCamelCase			:					List[str]     =    projection_dim
										_UpperCamelCase			:					str     =    logit_scale_init_value






				@classmethod
				def 				snake_case	( cls		:    Dict, lowerCAmelCase__		:    PretrainedConfig, lowerCAmelCase__		:    PretrainedConfig, **lowerCAmelCase__		:    Union[str, Any]							)	->      List[Any]:




										'''simple docstring'''



										return cls(vision_config=vision_config.to_dict(), text_config=text_config.to_dict(), **lowerCAmelCase__							)






				def 				snake_case	( self		:    str							)	->      Any:




										'''simple docstring'''



										_UpperCamelCase			:					str     =    copy.deepcopy(self.__dict__							)
										_UpperCamelCase			:					List[str]     =    self.vision_config.to_dict()
										_UpperCamelCase			:					List[Any]     =    self.text_config.to_dict()
										_UpperCamelCase			:					int     =    self.__class__.model_type
										return output










"""simple docstring"""




from __future__ import annotations





def        a_				(							_lowercase   ):
						assert (
						    isinstance(_lowercase       ,						_lowercase   ) and mask > 0
						), F"""mask needs to be positive integer, your input {mask}"""
						_UpperCamelCase			:					Union[str, Any]     =    []
						_UpperCamelCase			:					str     =    mask

						while submask:
												all_submasks.append(_lowercase   )
												_UpperCamelCase			:					int     =    (submask - 1) & mask

						return all_submasks


if __name__ == "__main__":
						import doctest

						doctest.testmod()



