



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  lowerCamelCase_   (    SCREAMING_SNAKE_CASE_					):
  """simple docstring"""




  a_							 ="""vision-text-dual-encoder"""
  a_							 =True




  def __init__(			self				:     Tuple      ,     _a				:     List[str]=512      ,     _a				:     List[str]=2.6592      ,     **_a				:     int       ) -> Union[str, Any]:
    super().__init__(**_a       )

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

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

    __lowerCamelCase	:	str   	=			vision_config.pop('model_type'       )
    __lowerCamelCase	:	str   	=			text_config.pop('model_type'       )

    if vision_model_type == "clip":
      __lowerCamelCase	:	Dict   	=			AutoConfig.for_model(_a      ,     **_a       ).vision_config
    elif vision_model_type == "clip_vision_model":
      __lowerCamelCase	:	str   	=			CLIPVisionConfig(**_a       )
    else:
      __lowerCamelCase	:	Union[str, Any]   	=			AutoConfig.for_model(_a      ,     **_a       )

    __lowerCamelCase	:	Any   	=			AutoConfig.for_model(_a      ,     **_a       )

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




  @classmethod
  def 						_lowercase					(			cls				:     Optional[int]      ,     _a				:     PretrainedConfig      ,     _a				:     PretrainedConfig      ,     **_a				:     Union[str, Any]       ) -> Tuple:
    return cls(vision_config=vision_config.to_dict()      ,     text_config=text_config.to_dict()      ,     **_a       )




  def 						_lowercase					(			self				:     int       ) -> List[str]:
    __lowerCamelCase	:	Optional[int]   	=			copy.deepcopy(self.__dict__       )
    __lowerCamelCase	:	Union[str, Any]   	=			self.vision_config.to_dict()
    __lowerCamelCase	:	Dict   	=			self.text_config.to_dict()
    __lowerCamelCase	:	int   	=			self.__class__.model_type
    return output











'''simple docstring'''





from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier

# Load iris file
_UpperCamelCase							    =						load_iris()
iris.keys()


print(f'''Target names: \n {iris.target_names} ''')
print(f'''\n Features: \n {iris.feature_names}''')

# Train set e Test set
_UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase    ,    _UpperCamelCase							    =						train_test_split(
    iris['data'], iris['target'], random_state=4
)

# KNN

_UpperCamelCase							    =						KNeighborsClassifier(n_neighbors=1)
knn.fit(X_train, y_train)

# new array to test
_UpperCamelCase							    =						[[1, 2, 1, 4], [2, 3, 4, 5]]

_UpperCamelCase							    =						knn.predict(X_new)

print(
    f'''\nNew array: \n {X_new}\n\nTarget Names Prediction: \n'''
    f''' {iris["target_names"][prediction]}'''
)






