


'''simple docstring'''

import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
   pass

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


lowercase__							=		logging.get_logger(__name__)

lowercase__							=		{
    "kakaobrain/align-base": "https://huggingface.co/kakaobrain/align-base/resolve/main/config.json",
}





class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''align_text_model'''






     def __init__(			self     ,							__UpperCamelCase=30_522     ,							__UpperCamelCase=768     ,							__UpperCamelCase=12     ,							__UpperCamelCase=12     ,							__UpperCamelCase=3_072     ,							__UpperCamelCase="gelu"     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=512     ,							__UpperCamelCase=2     ,							__UpperCamelCase=0.02     ,							__UpperCamelCase=1e-12     ,							__UpperCamelCase=0     ,							__UpperCamelCase="absolute"     ,							__UpperCamelCase=True     ,							**__UpperCamelCase     ,							)       ->    Union[str, Any]:
          super().__init__(**__A		)

          _a						=		vocab_size
          _a						=		hidden_size
          _a						=		num_hidden_layers
          _a						=		num_attention_heads
          _a						=		hidden_act
          _a						=		intermediate_size
          _a						=		hidden_dropout_prob
          _a						=		attention_probs_dropout_prob
          _a						=		max_position_embeddings
          _a						=		type_vocab_size
          _a						=		initializer_range
          _a						=		layer_norm_eps
          _a						=		position_embedding_type
          _a						=		use_cache
          _a						=		pad_token_id






     @classmethod
     def  a_					(			cls     ,							__UpperCamelCase     ,							**__UpperCamelCase		)       ->    "PretrainedConfig":
          cls._set_token_in_kwargs(__A		)

          _a			,			_a						=		cls.get_config_dict(__A     ,							**__A		)

          # get the text config dict if we are loading from AlignConfig
          if config_dict.get("model_type"		) == "align":
               _a						=		config_dict["text_config"]

          if "model_type" in config_dict and hasattr(cls     ,							"model_type"		) and config_dict["model_type"] != cls.model_type:
               logger.warning(
                   f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
                   f"{cls.model_type}. This is not supported for all configurations of models and can yield errors."		)

          return cls.from_dict(__A     ,							**__A		)







class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''align_vision_model'''






     def __init__(			self     ,							__UpperCamelCase = 3     ,							__UpperCamelCase = 600     ,							__UpperCamelCase = 2.0     ,							__UpperCamelCase = 3.1     ,							__UpperCamelCase = 8     ,							__UpperCamelCase = [3, 3, 5, 3, 5, 5, 3]     ,							__UpperCamelCase = [32, 16, 24, 40, 80, 112, 192]     ,							__UpperCamelCase = [16, 24, 40, 80, 112, 192, 320]     ,							__UpperCamelCase = []     ,							__UpperCamelCase = [1, 2, 2, 2, 1, 2, 1]     ,							__UpperCamelCase = [1, 2, 2, 3, 3, 4, 1]     ,							__UpperCamelCase = [1, 6, 6, 6, 6, 6, 6]     ,							__UpperCamelCase = 0.25     ,							__UpperCamelCase = "swish"     ,							__UpperCamelCase = 2_560     ,							__UpperCamelCase = "mean"     ,							__UpperCamelCase = 0.02     ,							__UpperCamelCase = 0.0_01     ,							__UpperCamelCase = 0.99     ,							__UpperCamelCase = 0.2     ,							**__UpperCamelCase     ,							)       ->    str:
          super().__init__(**__A		)

          _a						=		num_channels
          _a						=		image_size
          _a						=		width_coefficient
          _a						=		depth_coefficient
          _a						=		depth_divisor
          _a						=		kernel_sizes
          _a						=		in_channels
          _a						=		out_channels
          _a						=		depthwise_padding
          _a						=		strides
          _a						=		num_block_repeats
          _a						=		expand_ratios
          _a						=		squeeze_expansion_ratio
          _a						=		hidden_act
          _a						=		hidden_dim
          _a						=		pooling_type
          _a						=		initializer_range
          _a						=		batch_norm_eps
          _a						=		batch_norm_momentum
          _a						=		drop_connect_rate
          _a						=		sum(__A		) * 4






     @classmethod
     def  a_					(			cls     ,							__UpperCamelCase     ,							**__UpperCamelCase		)       ->    "PretrainedConfig":
          cls._set_token_in_kwargs(__A		)

          _a			,			_a						=		cls.get_config_dict(__A     ,							**__A		)

          # get the vision config dict if we are loading from AlignConfig
          if config_dict.get("model_type"		) == "align":
               _a						=		config_dict["vision_config"]

          if "model_type" in config_dict and hasattr(cls     ,							"model_type"		) and config_dict["model_type"] != cls.model_type:
               logger.warning(
                   f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
                   f"{cls.model_type}. This is not supported for all configurations of models and can yield errors."		)

          return cls.from_dict(__A     ,							**__A		)







class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''align'''
     UpperCAmelCase 					=				True






     def __init__(			self     ,							__UpperCamelCase=None     ,							__UpperCamelCase=None     ,							__UpperCamelCase=640     ,							__UpperCamelCase=1.0     ,							__UpperCamelCase=0.02     ,							**__UpperCamelCase     ,							)       ->    str:
          super().__init__(**__A		)

          if text_config is None:
               _a						=		{}
               logger.info("text_config is None. Initializing the AlignTextConfig with default values."		)

          if vision_config is None:
               _a						=		{}
               logger.info("vision_config is None. Initializing the AlignVisionConfig with default values."		)

          _a						=		AlignTextConfig(**__A		)
          _a						=		AlignVisionConfig(**__A		)

          _a						=		projection_dim
          _a						=		temperature_init_value
          _a						=		initializer_range






     @classmethod
     def  a_					(			cls     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							**__UpperCamelCase		)       ->    Union[str, Any]:
          return cls(text_config=text_config.to_dict()     ,							vision_config=vision_config.to_dict()     ,							**__A		)






     def  a_					(			self		)       ->    str:
          _a						=		copy.deepcopy(self.__dict__		)
          _a						=		self.text_config.to_dict()
          _a						=		self.vision_config.to_dict()
          _a						=		self.__class__.model_type
          return output





'''simple docstring'''

import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin





class 						__SCREAMING_SNAKE_CASE					(      unittest.TestCase ,			lowerCamelCase__ ):






     def  a_					(			self		)       ->    Tuple:
          _a						=		load_tool("text-classification"		)
          self.tool.setup()
          _a						=		load_tool("text-classification"     ,							remote=__UpperCamelCase		)






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		self.tool("That's quite cool"     ,							["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    Union[str, Any]:
          _a						=		self.remote_tool("That's quite cool"     ,							["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    Optional[int]:
          _a						=		self.tool(text="That's quite cool"     ,							labels=["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)






     def  a_					(			self		)       ->    str:
          _a						=		self.remote_tool(text="That's quite cool"     ,							labels=["positive", "negative"]		)
          self.assertEqual(__UpperCamelCase     ,							"positive"		)

