



'''simple docstring'''






import copy

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


lowerCamelCase__	  =		logging.get_logger(__name__)

class 	_lowerCAmelCase     (    __A       ):






		'''simple docstring'''
		snake_case_							= 'hybrid-clip'
		snake_case_							= True
		def __init__(						self							:       Optional[int]      ,		UpperCamelCase_							:       Union[str, Any]=512      ,		**UpperCamelCase_							:       Union[str, Any]		)      ->			Optional[Any]:







									'''simple docstring'''





									super().__init__(**UpperCamelCase_		)

									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`.'''		)

									_lowercase							:		str				=   kwargs.pop('''text_config'''		)
									_lowercase							:		Any				=   kwargs.pop('''vision_config'''		)

									_lowercase							:		Tuple				=   text_config.pop('''model_type'''		)
									_lowercase							:		Optional[int]				=   vision_config.pop('''model_type'''		)

									from transformers import AutoConfig

									_lowercase							:		Optional[int]				=   AutoConfig.for_model(UpperCamelCase_      ,		**UpperCamelCase_		)

									if vision_model_type == "clip":
																_lowercase							:		List[str]				=   AutoConfig.for_model(UpperCamelCase_      ,		**UpperCamelCase_		).vision_config
									elif vision_model_type == "clip_vision_model":
																from transformers import CLIPVisionConfig

																_lowercase							:		Union[str, Any]				=   CLIPVisionConfig(**UpperCamelCase_		)
									else:
																_lowercase							:		Tuple				=   AutoConfig.for_model(UpperCamelCase_      ,		**UpperCamelCase_		)

									_lowercase							:		Optional[int]				=   projection_dim
									_lowercase							:		str				=   1.0
		@classmethod
		def 						__lowercase      (						cls							:       Dict      ,		UpperCamelCase_							:       PretrainedConfig      ,		UpperCamelCase_							:       PretrainedConfig      ,		**UpperCamelCase_							:       Dict		)      ->			Tuple:







									'''simple docstring'''





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





		def 						__lowercase      (						self							:       List[str]		)      ->			int:







									'''simple docstring'''





									_lowercase							:		Dict				=   copy.deepcopy(self.__dict__		)
									_lowercase							:		int				=   self.text_config.to_dict()
									_lowercase							:		int				=   self.vision_config.to_dict()
									_lowercase							:		Optional[int]				=   self.__class__.model_type
									return output








'''simple docstring'''






import abc
import copy
import dataclasses
from dataclasses import dataclass
from typing import ClassVar, Dict, Type, TypeVar

from ..features import Features


lowerCamelCase__	  =		TypeVar('T', bound='TaskTemplate')

@dataclass(frozen=__A       )
class 	_lowerCAmelCase     (    abc.ABC       ):






		'''simple docstring'''
		# `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
		snake_case_							= 42
		snake_case_							= 42
		snake_case_							= 42
		def 						__lowercase      (						self							:       T      ,		UpperCamelCase_							:       Features		)      ->			T:







									'''simple docstring'''





									return copy.deepcopy(self		)
		@property
		def 						__lowercase      (						self							:       int		)      ->			Features:







									'''simple docstring'''





									return Features(**self.input_schema      ,		**self.label_schema		)
		@property
		@abc.abstractmethod
		def 						__lowercase      (						self							:       List[str]		)      ->			Dict[str, str]:







									'''simple docstring'''





									raise NotImplementedError





		@classmethod
		def 						__lowercase      (						cls							:       Type[T]      ,		UpperCamelCase_							:       dict		)      ->			T:







									'''simple docstring'''





									_lowercase							:		List[str]				=   {f.name for f in dataclasses.fields(cls		)}
									return cls(**{k: v for k, v in template_dict.items() if k in field_names}		)



