





import copy
from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


if TYPE_CHECKING:
      from ... import PreTrainedTokenizerBase, TensorType

SCREAMING_SNAKE_CASE_		     = logging.get_logger(__name__)

class 	UpperCamelCase__				(   lowerCAmelCase_     ):



     '''simple docstring'''

     __snake_case					:			Tuple				=    "vision-encoder-decoder"
     __snake_case					:			List[Any]				=    True






     def __init__(							self		:					Union[str, Any]		,**lowerCamelCase__		:					Optional[Any] )  ->	List[Any]:




           '''simple docstring'''


           super().__init__(**lowerCamelCase__ )
           if "encoder" not in kwargs or "decoder" not in kwargs:
                 raise ValueError(
                     F"""A configuraton of type {self.model_type} cannot be instantiated because """
                     F"""not both `encoder` and `decoder` sub-configurations are passed, but only {kwargs}""" )

           SCREAMING_SNAKE_CASE	=		kwargs.pop("""encoder""" )
           SCREAMING_SNAKE_CASE	=		encoder_config.pop("""model_type""" )
           SCREAMING_SNAKE_CASE	=		kwargs.pop("""decoder""" )
           SCREAMING_SNAKE_CASE	=		decoder_config.pop("""model_type""" )

           SCREAMING_SNAKE_CASE	=		AutoConfig.for_model(lowerCamelCase__		,**lowerCamelCase__ )
           SCREAMING_SNAKE_CASE	=		AutoConfig.for_model(lowerCamelCase__		,**lowerCamelCase__ )
           SCREAMING_SNAKE_CASE	=		True






     @classmethod
     def        SCREAMING_SNAKE_CASE__						(							cls		:					Dict		,lowerCamelCase__		:					PretrainedConfig		,lowerCamelCase__		:					PretrainedConfig		,**lowerCamelCase__		:					Dict )  ->	PretrainedConfig:




           '''simple docstring'''


           logger.info("""Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config""" )
           SCREAMING_SNAKE_CASE	=		True
           SCREAMING_SNAKE_CASE	=		True

           return cls(encoder=encoder_config.to_dict()		,decoder=decoder_config.to_dict()		,**lowerCamelCase__ )






     def        SCREAMING_SNAKE_CASE__						(							self		:					Union[str, Any] )  ->	List[Any]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE	=		copy.deepcopy(self.__dict__ )
           SCREAMING_SNAKE_CASE	=		self.encoder.to_dict()
           SCREAMING_SNAKE_CASE	=		self.decoder.to_dict()
           SCREAMING_SNAKE_CASE	=		self.__class__.model_type
           return output

class 	UpperCamelCase__				(   lowerCAmelCase_     ):



     '''simple docstring'''

     __snake_case					:			Union[str, Any]				=    version.parse("1.11"     )






     @property
     def        SCREAMING_SNAKE_CASE__						(							self		:					List[str] )  ->	Mapping[str, Mapping[int, str]]:




           '''simple docstring'''


           return OrderedDict(
               [
                   ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
               ] )






     @property
     def        SCREAMING_SNAKE_CASE__						(							self		:					str )  ->	float:




           '''simple docstring'''


           return 1e-4






     @property
     def        SCREAMING_SNAKE_CASE__						(							self		:					List[str] )  ->	Mapping[str, Mapping[int, str]]:




           '''simple docstring'''


           return OrderedDict({"""last_hidden_state""": {0: """batch""", 1: """encoder_sequence"""}} )

class 	UpperCamelCase__				(   lowerCAmelCase_     ):



     '''simple docstring'''

     @property
     def        SCREAMING_SNAKE_CASE__						(							self		:					Union[str, Any] )  ->	Mapping[str, Mapping[int, str]]:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE	=		OrderedDict()
           SCREAMING_SNAKE_CASE	=		{0: """batch""", 1: """past_decoder_sequence + sequence"""}
           SCREAMING_SNAKE_CASE	=		{0: """batch""", 1: """past_decoder_sequence + sequence"""}
           SCREAMING_SNAKE_CASE	=		{0: """batch""", 1: """encoder_sequence"""}

           return common_inputs






     def        SCREAMING_SNAKE_CASE__						(							self		:					List[Any]		,lowerCamelCase__		:					"PreTrainedTokenizerBase"		,lowerCamelCase__		:					int = -1		,lowerCamelCase__		:					int = -1		,lowerCamelCase__		:					bool = False		,lowerCamelCase__		:					Optional["TensorType"] = None		,)  ->	Mapping[str, Any]:




           '''simple docstring'''


           import torch

           SCREAMING_SNAKE_CASE	=		OrderedDict()

           SCREAMING_SNAKE_CASE	=		super().generate_dummy_inputs(
               lowerCamelCase__		,batch_size=lowerCamelCase__		,seq_length=lowerCamelCase__		,is_pair=lowerCamelCase__		,framework=lowerCamelCase__ )

           SCREAMING_SNAKE_CASE,      SCREAMING_SNAKE_CASE	=		dummy_input["""input_ids"""].shape
           SCREAMING_SNAKE_CASE	=		(batch, encoder_sequence, self._config.encoder_hidden_size)
           SCREAMING_SNAKE_CASE	=		dummy_input.pop("""input_ids""" )
           SCREAMING_SNAKE_CASE	=		dummy_input.pop("""attention_mask""" )
           SCREAMING_SNAKE_CASE	=		torch.zeros(lowerCamelCase__ )

           return common_inputs

class 	UpperCamelCase__				(   lowerCAmelCase_     ):



     '''simple docstring'''

     @property
     def        SCREAMING_SNAKE_CASE__						(							self		:					List[Any] )  ->	None:




           '''simple docstring'''


           pass






     def        SCREAMING_SNAKE_CASE__						(							self		:					int		,lowerCamelCase__		:					PretrainedConfig )  ->	OnnxConfig:




           '''simple docstring'''


           return VisionEncoderDecoderEncoderOnnxConfig(lowerCamelCase__ )






     def        SCREAMING_SNAKE_CASE__						(							self		:					List[str]		,lowerCamelCase__		:					PretrainedConfig		,lowerCamelCase__		:					PretrainedConfig		,lowerCamelCase__		:					str = "default" )  ->	OnnxConfig:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE	=		encoder_config.hidden_size
           return VisionEncoderDecoderDecoderOnnxConfig(lowerCamelCase__		,lowerCamelCase__ )









import os
from datetime import datetime as dt

from github import Github


SCREAMING_SNAKE_CASE_		     = [
    """good first issue""",
    """feature request""",
    """wip""",
]



def      __lowercase     (   )				->     Optional[int]:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE	=		Github(os.environ["""GITHUB_TOKEN"""]			)
      SCREAMING_SNAKE_CASE	=		g.get_repo("""huggingface/accelerate"""			)
      SCREAMING_SNAKE_CASE	=		repo.get_issues(state="""open"""			)

      for issue in open_issues:
            SCREAMING_SNAKE_CASE	=		sorted([comment for comment in issue.get_comments()]				,		key=lambda _SCREAMING_SNAKE_CASE			: i.created_at				,		reverse=_SCREAMING_SNAKE_CASE			)
            SCREAMING_SNAKE_CASE	=		comments[0] if len(_SCREAMING_SNAKE_CASE			) > 0 else None
            SCREAMING_SNAKE_CASE	=		dt.utcnow()
            SCREAMING_SNAKE_CASE	=		(current_time - issue.updated_at).days
            SCREAMING_SNAKE_CASE	=		(current_time - issue.created_at).days
            if (
                last_comment is not None
                and last_comment.user.login == "github-actions[bot]"
                and days_since_updated > 7
                and days_since_creation >= 30
                and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()			)
            ):
                  # Close issue since it has been 7 days of inactivity since bot mention.
                  issue.edit(state="""closed"""			)
            elif (
                days_since_updated > 23
                and days_since_creation >= 30
                and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()			)
            ):
                  # Add stale comment
                  issue.create_comment(
                      """This issue has been automatically marked as stale because it has not had """
                      """recent activity. If you think this still needs to be addressed """
                      """please comment on this thread.\n\nPlease note that issues that do not follow the """
                      """[contributing guidelines](https://github.com/huggingface/accelerate/blob/main/CONTRIBUTING.md) """
                      """are likely to be ignored."""			)


if __name__ == "__main__":
      main()


