






import inspect
import tempfile
from collections import OrderedDict, UserDict
from collections.abc import MutableMapping
from contextlib import ExitStack, contextmanager
from dataclasses import fields
from enum import Enum
from typing import Any, ContextManager, List, Tuple

import numpy as np

from .import_utils import is_flax_available, is_tf_available, is_torch_available, is_torch_fx_proxy


if is_flax_available():
       import jax.numpy as jnp
class     a    ( lowercase__   ):



      """simple docstring"""


      def __get__(      self					:			Union[str, Any]		,      __lowercase					:			Dict		,      __lowercase					:			str=None					)							->      Dict:
        # See docs.python.org/3/howto/descriptor.html#properties
        if obj is None:
          return self
        if self.fget is None:
          raise AttributeError("""unreadable attribute"""					)
        __UpperCAmelCase							:	str           =  """__cached_""" + self.fget.__name__
        __UpperCAmelCase							:	Optional[Any]           =  getattr(__lowercase		,      __lowercase		,      __lowercase					)
        if cached is None:
          __UpperCAmelCase							:	List[Any]           =  self.fget(__lowercase					)
          setattr(__lowercase		,      __lowercase		,      __lowercase					)
        return cached






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[str]		):
  __UpperCAmelCase							:	List[Any]           =  val.lower()
  if val in {"y", "yes", "t", "true", "on", "1"}:
    return 1
  if val in {"n", "no", "f", "false", "off", "0"}:
    return 0
  raise ValueError(f"""invalid truth value {val!r}"""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Union[str, Any]		):
  if is_torch_fx_proxy(__lowerCamelCase		):
    return True
  if is_torch_available():
    import torch

    if isinstance(__lowerCamelCase  ,		torch.Tensor		):
      return True
  if is_tf_available():
    import tensorflow as tf

    if isinstance(__lowerCamelCase  ,		tf.Tensor		):
      return True

  if is_flax_available():
    import jax.numpy as jnp
    from jax.core import Tracer

    if isinstance(__lowerCamelCase  ,		(jnp.ndarray, Tracer)		):
      return True

  return isinstance(__lowerCamelCase  ,		np.ndarray		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     str		):
  return isinstance(__lowerCamelCase  ,		np.ndarray		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[int]		):
  return _is_numpy(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     int		):
  import torch

  return isinstance(__lowerCamelCase  ,		torch.Tensor		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Any		):
  return False if not is_torch_available() else _is_torch(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Any		):
  import torch

  return isinstance(__lowerCamelCase  ,		torch.device		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Dict		):
  return False if not is_torch_available() else _is_torch_device(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[str]		):
  import torch

  if isinstance(__lowerCamelCase  ,		__lowerCamelCase		):
    if hasattr(__lowerCamelCase  ,		__lowerCamelCase		):
      __UpperCAmelCase							:	Optional[int]           =  getattr(__lowerCamelCase  ,		__lowerCamelCase		)
    else:
      return False
  return isinstance(__lowerCamelCase  ,		torch.dtype		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[Any]		):
  return False if not is_torch_available() else _is_torch_dtype(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[Any]		):
  import tensorflow as tf

  return isinstance(__lowerCamelCase  ,		tf.Tensor		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     int		):
  return False if not is_tf_available() else _is_tensorflow(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[int]		):
  import tensorflow as tf

  # the `is_symbolic_tensor` predicate is only available starting with TF 2.14
  if hasattr(__lowerCamelCase  ,		"""is_symbolic_tensor"""		):
    return tf.is_symbolic_tensor(__lowerCamelCase		)
  return type(__lowerCamelCase		) == tf.Tensor






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[Any]		):
  return False if not is_tf_available() else _is_tf_symbolic_tensor(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Dict		):
  import jax.numpy as jnp  # noqa: F811

  return isinstance(__lowerCamelCase  ,		jnp.ndarray		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Dict		):
  return False if not is_flax_available() else _is_jax(__lowerCamelCase		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[int]		):
  if isinstance(__lowerCamelCase  ,		(dict, UserDict)		):
    return {k: to_py_obj(__lowerCamelCase		) for k, v in obj.items()}
  elif isinstance(__lowerCamelCase  ,		(list, tuple)		):
    return [to_py_obj(__lowerCamelCase		) for o in obj]
  elif is_tf_tensor(__lowerCamelCase		):
    return obj.numpy().tolist()
  elif is_torch_tensor(__lowerCamelCase		):
    return obj.detach().cpu().tolist()
  elif is_jax_tensor(__lowerCamelCase		):
    return np.asarray(__lowerCamelCase		).tolist()
  elif isinstance(__lowerCamelCase  ,		(np.ndarray, np.number)		):  # tolist also works on 0d np arrays
    return obj.tolist()
  else:
    return obj






def 				lowerCamelCase__      (    __lowerCamelCase			:     str		):
  if isinstance(__lowerCamelCase  ,		(dict, UserDict)		):
    return {k: to_numpy(__lowerCamelCase		) for k, v in obj.items()}
  elif isinstance(__lowerCamelCase  ,		(list, tuple)		):
    return np.array(__lowerCamelCase		)
  elif is_tf_tensor(__lowerCamelCase		):
    return obj.numpy()
  elif is_torch_tensor(__lowerCamelCase		):
    return obj.detach().cpu().numpy()
  elif is_jax_tensor(__lowerCamelCase		):
    return np.asarray(__lowerCamelCase		)
  else:
    return obj
class     a    ( lowercase__   ):



      """simple docstring"""


      def 	UpperCAmelCase      (      self					:			str					)							->      Tuple:
        __UpperCAmelCase							:	Optional[int]           =  fields(self					)

        # Safety and consistency checks
        if not len(__lowercase					):
          raise ValueError(f"""{self.__class__.__name__} has no fields."""					)
        if not all(field.default is None for field in class_fields[1:]					):
          raise ValueError(f"""{self.__class__.__name__} should not have more than one required field."""					)

        __UpperCAmelCase							:	Optional[Any]           =  getattr(self		,      class_fields[0].name					)
        __UpperCAmelCase							:	Dict           =  all(getattr(self		,      field.name					) is None for field in class_fields[1:]					)

        if other_fields_are_none and not is_tensor(__lowercase					):
          if isinstance(__lowercase		,      __lowercase					):
            __UpperCAmelCase							:	Optional[Any]           =  first_field.items()
            __UpperCAmelCase							:	Optional[int]           =  True
          else:
            try:
              __UpperCAmelCase							:	List[Any]           =  iter(__lowercase					)
              __UpperCAmelCase							:	Optional[Any]           =  True
            except TypeError:
              __UpperCAmelCase							:	Any           =  False

            # if we provided an iterator as first field and the iterator is a (key, value) iterator
            # set the associated fields
          if first_field_iterator:
            for idx, element in enumerate(__lowercase					):
              if (
                  not isinstance(__lowercase		,      (list, tuple)					)
                  or not len(__lowercase					) == 2
                  or not isinstance(element[0]		,      __lowercase					)
              ):
                if idx == 0:
                  # If we do not have an iterator of key/values, set it as attribute
                  __UpperCAmelCase							:	Optional[int]           =  first_field
                else:
                  # If we have a mixed iterator, raise an error
                  raise ValueError(
                      f"""Cannot set key/value for {element}. It needs to be a tuple (key, value)."""					)
                break
              setattr(self		,      element[0]		,      element[1]					)
              if element[1] is not None:
                __UpperCAmelCase							:	Tuple           =  element[1]
          elif first_field is not None:
            __UpperCAmelCase							:	Optional[int]           =  first_field
        else:
          for field in class_fields:
            __UpperCAmelCase							:	List[Any]           =  getattr(self		,      field.name					)
            if v is not None:
              __UpperCAmelCase							:	str           =  v
      def __delitem__(      self					:			Tuple		,      *__lowercase					:			Tuple		,      **__lowercase					:			Union[str, Any]					)							->      Optional[Any]:
        raise Exception(f"""You cannot use ``__delitem__`` on a {self.__class__.__name__} instance."""					)
      def 	UpperCAmelCase      (      self					:			Union[str, Any]		,      *__lowercase					:			Union[str, Any]		,      **__lowercase					:			Optional[int]					)							->      int:
        raise Exception(f"""You cannot use ``setdefault`` on a {self.__class__.__name__} instance."""					)
      def 	UpperCAmelCase      (      self					:			Union[str, Any]		,      *__lowercase					:			Optional[Any]		,      **__lowercase					:			int					)							->      Union[str, Any]:
        raise Exception(f"""You cannot use ``pop`` on a {self.__class__.__name__} instance."""					)
      def 	UpperCAmelCase      (      self					:			Union[str, Any]		,      *__lowercase					:			int		,      **__lowercase					:			Union[str, Any]					)							->      Dict:
        raise Exception(f"""You cannot use ``update`` on a {self.__class__.__name__} instance."""					)
      def __getitem__(      self					:			Any		,      __lowercase					:			Dict					)							->      List[str]:
        if isinstance(__lowercase		,      __lowercase					):
          __UpperCAmelCase							:	Union[str, Any]           =  dict(self.items()					)
          return inner_dict[k]
        else:
          return self.to_tuple()[k]
      def __setattr__(      self					:			int		,      __lowercase					:			Optional[int]		,      __lowercase					:			List[Any]					)							->      Dict:
        if name in self.keys() and value is not None:
          # Don't call self.__setitem__ to avoid recursion errors
          super().__setitem__(__lowercase		,      __lowercase					)
        super().__setattr__(__lowercase		,      __lowercase					)
      def __setitem__(      self					:			List[str]		,      __lowercase					:			str		,      __lowercase					:			str					)							->      int:
        # Will raise a KeyException if needed
        super().__setitem__(__lowercase		,      __lowercase					)
        # Don't call self.__setattr__ to avoid recursion errors
        super().__setattr__(__lowercase		,      __lowercase					)




      def 	UpperCAmelCase      (      self					:			List[Any]					)							->      Tuple[Any]:
        return tuple(self[k] for k in self.keys()					)


class     a    ( lowercase__							,       lowercase__   ):



      """simple docstring"""


      @classmethod
      def 	UpperCAmelCase      (      cls					:			Union[str, Any]		,      __lowercase					:			Optional[Any]					)							->      Optional[int]:
        raise ValueError(
            f"""{value} is not a valid {cls.__name__}, please select one of {list(cls._valueamember_map_.keys()					)}"""					)


class     a    ( lowercase__   ):



      """simple docstring"""


      a  : Dict							       =	'longest'
      a  : int							       =	'max_length'
      a  : Dict							       =	'do_not_pad'


class     a    ( lowercase__   ):



      """simple docstring"""


      a  : int							       =	'pt'
      a  : Union[str, Any]							       =	'tf'
      a  : Optional[Any]							       =	'np'
      a  : Union[str, Any]							       =	'jax'


class     a    :



      """simple docstring"""


      def __init__(      self					:			List[Any]		,      __lowercase					:			List[ContextManager]					)							->      Dict:
        __UpperCAmelCase							:	Optional[int]           =  context_managers
        __UpperCAmelCase							:	Tuple           =  ExitStack()
      def __enter__(      self					:			Any					)							->      List[str]:
        for context_manager in self.context_managers:
          self.stack.enter_context(__lowercase					)




      def __exit__(      self					:			Any		,      *__lowercase					:			List[Any]		,      **__lowercase					:			Tuple					)							->      Any:
        self.stack.__exit__(*__lowercase		,      **__lowercase					)






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[str]		):
  __UpperCAmelCase							:	Tuple           =  infer_framework(__lowerCamelCase		)
  if framework == "tf":
    __UpperCAmelCase							:	Union[str, Any]           =  inspect.signature(model_class.call		)  # TensorFlow models
  elif framework == "pt":
    __UpperCAmelCase							:	List[Any]           =  inspect.signature(model_class.forward		)  # PyTorch models
  else:
    __UpperCAmelCase							:	List[Any]           =  inspect.signature(model_class.__call__		)  # Flax models

  for p in signature.parameters:
    if p == "return_loss" and signature.parameters[p].default is True:
      return True

  return False






def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[Any]		):
  __UpperCAmelCase							:	Union[str, Any]           =  model_class.__name__
  __UpperCAmelCase							:	Tuple           =  infer_framework(__lowerCamelCase		)
  if framework == "tf":
    __UpperCAmelCase							:	Any           =  inspect.signature(model_class.call		)  # TensorFlow models
  elif framework == "pt":
    __UpperCAmelCase							:	str           =  inspect.signature(model_class.forward		)  # PyTorch models
  else:
    __UpperCAmelCase							:	Any           =  inspect.signature(model_class.__call__		)  # Flax models

  if "QuestionAnswering" in model_name:
    return [p for p in signature.parameters if "label" in p or p in ("start_positions", "end_positions")]
  else:
    return [p for p in signature.parameters if "label" in p]






def 				lowerCamelCase__      (    __lowerCamelCase			:     MutableMapping  ,		__lowerCamelCase			:     str = ""  ,		__lowerCamelCase			:     str = "."		):

  def _flatten_dict(__lowerCamelCase			:     Union[str, Any]  ,		__lowerCamelCase			:     str=""  ,		__lowerCamelCase			:     Any="."		):
    for k, v in d.items():
      __UpperCAmelCase							:	int           =  str(__lowerCamelCase		) + delimiter + str(__lowerCamelCase		) if parent_key else k
      if v and isinstance(__lowerCamelCase  ,		__lowerCamelCase		):
        yield from flatten_dict(__lowerCamelCase  ,		__lowerCamelCase  ,		delimiter=__lowerCamelCase		).items()
      else:
        yield key, v

  return dict(_flatten_dict(__lowerCamelCase  ,		__lowerCamelCase  ,		__lowerCamelCase		)		)






@contextmanager
def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[Any]  ,		__lowerCamelCase			:     bool = False		):
  if use_temp_dir:
    with tempfile.TemporaryDirectory() as tmp_dir:
      yield tmp_dir
  else:
    yield working_dir






def 				lowerCamelCase__      (    __lowerCamelCase			:     str  ,		__lowerCamelCase			:     List[str]=None		):
  if is_numpy_array(__lowerCamelCase		):
    return np.transpose(__lowerCamelCase  ,		axes=__lowerCamelCase		)
  elif is_torch_tensor(__lowerCamelCase		):
    return array.T if axes is None else array.permute(*__lowerCamelCase		)
  elif is_tf_tensor(__lowerCamelCase		):
    import tensorflow as tf

    return tf.transpose(__lowerCamelCase  ,		perm=__lowerCamelCase		)
  elif is_jax_tensor(__lowerCamelCase		):
    return jnp.transpose(__lowerCamelCase  ,		axes=__lowerCamelCase		)
  else:
    raise ValueError(f"""Type not supported for transpose: {type(__lowerCamelCase		)}."""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Optional[int]  ,		__lowerCamelCase			:     Tuple		):
  if is_numpy_array(__lowerCamelCase		):
    return np.reshape(__lowerCamelCase  ,		__lowerCamelCase		)
  elif is_torch_tensor(__lowerCamelCase		):
    return array.reshape(*__lowerCamelCase		)
  elif is_tf_tensor(__lowerCamelCase		):
    import tensorflow as tf

    return tf.reshape(__lowerCamelCase  ,		__lowerCamelCase		)
  elif is_jax_tensor(__lowerCamelCase		):
    return jnp.reshape(__lowerCamelCase  ,		__lowerCamelCase		)
  else:
    raise ValueError(f"""Type not supported for reshape: {type(__lowerCamelCase		)}."""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     Tuple  ,		__lowerCamelCase			:     Optional[Any]=None		):
  if is_numpy_array(__lowerCamelCase		):
    return np.squeeze(__lowerCamelCase  ,		axis=__lowerCamelCase		)
  elif is_torch_tensor(__lowerCamelCase		):
    return array.squeeze() if axis is None else array.squeeze(dim=__lowerCamelCase		)
  elif is_tf_tensor(__lowerCamelCase		):
    import tensorflow as tf

    return tf.squeeze(__lowerCamelCase  ,		axis=__lowerCamelCase		)
  elif is_jax_tensor(__lowerCamelCase		):
    return jnp.squeeze(__lowerCamelCase  ,		axis=__lowerCamelCase		)
  else:
    raise ValueError(f"""Type not supported for squeeze: {type(__lowerCamelCase		)}."""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     List[Any]  ,		__lowerCamelCase			:     Optional[int]		):
  if is_numpy_array(__lowerCamelCase		):
    return np.expand_dims(__lowerCamelCase  ,		__lowerCamelCase		)
  elif is_torch_tensor(__lowerCamelCase		):
    return array.unsqueeze(dim=__lowerCamelCase		)
  elif is_tf_tensor(__lowerCamelCase		):
    import tensorflow as tf

    return tf.expand_dims(__lowerCamelCase  ,		axis=__lowerCamelCase		)
  elif is_jax_tensor(__lowerCamelCase		):
    return jnp.expand_dims(__lowerCamelCase  ,		axis=__lowerCamelCase		)
  else:
    raise ValueError(f"""Type not supported for expand_dims: {type(__lowerCamelCase		)}."""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     str		):
  if is_numpy_array(__lowerCamelCase		):
    return np.size(__lowerCamelCase		)
  elif is_torch_tensor(__lowerCamelCase		):
    return array.numel()
  elif is_tf_tensor(__lowerCamelCase		):
    import tensorflow as tf

    return tf.size(__lowerCamelCase		)
  elif is_jax_tensor(__lowerCamelCase		):
    return array.size
  else:
    raise ValueError(f"""Type not supported for expand_dims: {type(__lowerCamelCase		)}."""		)






def 				lowerCamelCase__      (    __lowerCamelCase			:     str  ,		__lowerCamelCase			:     int		):
  for key, value in auto_map.items():
    if isinstance(__lowerCamelCase  ,		(tuple, list)		):
      __UpperCAmelCase							:	Any           =  [f"""{repo_id}--{v}""" if (v is not None and """--""" not in v) else v for v in value]
    elif value is not None and "--" not in value:
      __UpperCAmelCase							:	Tuple           =  f"""{repo_id}--{value}"""

  return auto_map







def 				lowerCamelCase__      (    __lowerCamelCase			:     List[Any]		):
  for base_class in inspect.getmro(__lowerCamelCase		):
    __UpperCAmelCase							:	List[str]           =  base_class.__module__
    __UpperCAmelCase							:	Optional[int]           =  base_class.__name__
    if module.startswith("""tensorflow"""		) or module.startswith("""keras"""		) or name == "TFPreTrainedModel":
      return "tf"
    elif module.startswith("""torch"""		) or name == "PreTrainedModel":
      return "pt"
    elif module.startswith("""flax"""		) or module.startswith("""jax"""		) or name == "FlaxPreTrainedModel":
      return "flax"
  else:
    raise TypeError(f"""Could not infer framework from class {model_class}."""		)










import copy
from typing import Dict, Optional

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING
from ..detr import DetrConfig
from ..swin import SwinConfig


a		:       Optional[Any]			     = {
    "facebook/maskformer-swin-base-ade": (
        "https://huggingface.co/facebook/maskformer-swin-base-ade/blob/main/config.json"
    )
    # See all MaskFormer models at https://huggingface.co/models?filter=maskformer
}

a		:       Optional[Any]			     = logging.get_logger(__name__)
class     a    ( lowercase__   ):



      """simple docstring"""


      a  : str							       =	'maskformer'
      a  : Dict							       =	{'hidden_size': 'mask_feature_size'}
      a  : Optional[Any]							       =	['resnet', 'swin']
      a  : List[Any]							       =	['detr']
      def __init__(      self					:			Optional[int]		,      __lowercase					:			int = 256		,      __lowercase					:			int = 256		,      __lowercase					:			float = 0.1		,      __lowercase					:			bool = False		,      __lowercase					:			Optional[Dict] = None		,      __lowercase					:			Optional[Dict] = None		,      __lowercase					:			float = 0.02		,      __lowercase					:			float = 1.0		,      __lowercase					:			float = 1.0		,      __lowercase					:			float = 1.0		,      __lowercase					:			float = 20.0		,      __lowercase					:			Optional[bool] = None		,      **__lowercase					:			Tuple		,      )							->      str:
        if backbone_config is None:
          # fall back to https://huggingface.co/microsoft/swin-base-patch4-window12-384-in22k
          __UpperCAmelCase							:	List[str]           =  SwinConfig(
              image_size=384		,      in_channels=3		,      patch_size=4		,      embed_dim=128		,      depths=[2, 2, 18, 2]		,      num_heads=[4, 8, 16, 32]		,      window_size=12		,      drop_path_rate=0.3		,      out_features=["""stage1""", """stage2""", """stage3""", """stage4"""]		,      )

        if isinstance(__lowercase		,      __lowercase					):
          __UpperCAmelCase							:	Dict           =  backbone_config.pop("""model_type"""					)
          __UpperCAmelCase							:	Tuple           =  CONFIG_MAPPING[backbone_model_type]
          __UpperCAmelCase							:	List[str]           =  config_class.from_dict(__lowercase					)

        # verify that the backbone is supported
        if backbone_config.model_type not in self.backbones_supported:
          logger.warning_once(
              f"""Backbone {backbone_config.model_type} is not a supported model and may not be compatible with MaskFormer. """
              f"""Supported model types: {",".join(self.backbones_supported					)}"""					)

        if decoder_config is None:
          # fall back to https://huggingface.co/facebook/detr-resnet-50
          __UpperCAmelCase							:	List[Any]           =  DetrConfig()
        else:
          # verify that the decoder is supported
          __UpperCAmelCase							:	List[Any]           =  (
              decoder_config.pop("""model_type"""					) if isinstance(__lowercase		,      __lowercase					) else decoder_config.model_type
          )
          if decoder_type not in self.decoders_supported:
            raise ValueError(
                f"""Transformer Decoder {decoder_type} not supported, please use one of"""
                f""" {",".join(self.decoders_supported					)}"""					)
          if isinstance(__lowercase		,      __lowercase					):
            __UpperCAmelCase							:	Dict           =  CONFIG_MAPPING[decoder_type]
            __UpperCAmelCase							:	Union[str, Any]           =  config_class.from_dict(__lowercase					)

        __UpperCAmelCase							:	Optional[Any]           =  backbone_config
        __UpperCAmelCase							:	List[str]           =  decoder_config
        # main feature dimension for the model
        __UpperCAmelCase							:	Union[str, Any]           =  fpn_feature_size
        __UpperCAmelCase							:	Optional[Any]           =  mask_feature_size
        # initializer
        __UpperCAmelCase							:	int           =  init_std
        __UpperCAmelCase							:	Any           =  init_xavier_std
        # Hungarian matcher && loss
        __UpperCAmelCase							:	Any           =  cross_entropy_weight
        __UpperCAmelCase							:	Optional[Any]           =  dice_weight
        __UpperCAmelCase							:	List[str]           =  mask_weight
        __UpperCAmelCase							:	Union[str, Any]           =  use_auxiliary_loss
        __UpperCAmelCase							:	int           =  no_object_weight
        __UpperCAmelCase							:	int           =  output_auxiliary_logits

        __UpperCAmelCase							:	Optional[Any]           =  self.decoder_config.encoder_attention_heads
        __UpperCAmelCase							:	Dict           =  self.decoder_config.num_hidden_layers
        super().__init__(**__lowercase					)
      @classmethod
      def 	UpperCAmelCase      (      cls					:			int		,      __lowercase					:			PretrainedConfig		,      __lowercase					:			PretrainedConfig		,      **__lowercase					:			str					)							->      Tuple:
        return cls(
            backbone_config=__lowercase		,      decoder_config=__lowercase		,      **__lowercase		,      )




      def 	UpperCAmelCase      (      self					:			List[Any]					)							->      Dict[str, any]:
        __UpperCAmelCase							:	Optional[Any]           =  copy.deepcopy(self.__dict__					)
        __UpperCAmelCase							:	Optional[int]           =  self.backbone_config.to_dict()
        __UpperCAmelCase							:	Any           =  self.decoder_config.to_dict()
        __UpperCAmelCase							:	Tuple           =  self.__class__.model_type
        return output


