'''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


_lowerCamelCase :				str														= logging.get_logger(__name__)




class    lowerCamelCase__  (   __snake_case     ):
   __UpperCAmelCase           =						"""vision-text-dual-encoder"""
   __UpperCAmelCase           =						True



   def __init__(    self					,      lowerCAmelCase__=512					,      lowerCAmelCase__=2.6592					,      **lowerCAmelCase__     )				->     str:
        """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  :Optional[int]       =kwargs.pop("""vision_config"""     )
        _UpperCamelCase  :List[Any]       =kwargs.pop("""text_config"""     )

        _UpperCamelCase  :Union[str, Any]       =vision_config.pop("""model_type"""     )
        _UpperCamelCase  :Tuple       =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  :Union[str, Any]       =CLIPVisionConfig(**lowerCAmelCase__     )
        else:
             _UpperCamelCase  :List[str]       =AutoConfig.for_model(lowerCAmelCase__					,      **lowerCAmelCase__     )

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

        _UpperCamelCase  :Any       =projection_dim
        _UpperCamelCase  :Tuple       =logit_scale_init_value



   @classmethod
   def  _UpperCamelCase		(    cls					,      lowerCAmelCase__					,      lowerCAmelCase__					,      **lowerCAmelCase__     )				->     List[Any]:
        """simple docstring"""





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




   def  _UpperCamelCase		(    self     )				->     Optional[int]:
        """simple docstring"""





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


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_torch_available,
)


UpperCAmelCase__			:  Tuple					     =     {
    """configuration_speech_to_text_2""": ["""SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2Text2Config"""],
    """processing_speech_to_text_2""": ["""Speech2Text2Processor"""],
    """tokenization_speech_to_text_2""": ["""Speech2Text2Tokenizer"""],
}


try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  UpperCAmelCase__			:  Tuple					     =     [
      """SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """Speech2Text2ForCausalLM""",
      """Speech2Text2PreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_speech_to_text_a import SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextaConfig
  from .processing_speech_to_text_a import SpeechaTextaProcessor
  from .tokenization_speech_to_text_a import SpeechaTextaTokenizer

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_speech_to_text_a import (
        SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST,
        SpeechaTextaForCausalLM,
        SpeechaTextaPreTrainedModel,
    )

else:
  import sys

  UpperCAmelCase__			:  Optional[int]					     =     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




