




import copy

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


__A    :				Union[str, Any]    						=	logging.get_logger(__name__)




class       UpperCAmelCase_   ( A							):




							'''simple docstring'''



							a__    	=  '''speech-encoder-decoder'''
							a__    	=  True





							def __init__(       self							:						Optional[int]							,  **a							:						Dict      )      ->       Tuple:
										super().__init__(**a      )
										if "encoder" not in kwargs or "decoder" not in kwargs:
													raise ValueError(
													    f"""A configuraton of type {self.model_type} cannot be instantiated because not both `encoder` and"""
													    f""" `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(a							,  **a      )
										SCREAMING_SNAKE_CASE     =       AutoConfig.for_model(a							,  **a      )
										SCREAMING_SNAKE_CASE     =       True





							@classmethod
							def  _UpperCAmelCase  (       cls							:						Union[str, Any]							,  a							:						PretrainedConfig							,  a							:						PretrainedConfig							,  **a							:						Tuple      )      ->       PretrainedConfig:
										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()							,  **a      )







							def  _UpperCAmelCase  (       self							:						Tuple      )      ->       str:
										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












import argparse

from transformers import ConvBertConfig, ConvBertModel, TFConvBertModel, load_tf_weights_in_convbert
from transformers.utils import logging


logging.set_verbosity_info()
def        lowerCamelCase_     (     SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE ):
			'''simple docstring'''
			SCREAMING_SNAKE_CASE     =       ConvBertConfig.from_json_file(SCREAMING_SNAKE_CASE )
			SCREAMING_SNAKE_CASE     =       ConvBertModel(SCREAMING_SNAKE_CASE )

			SCREAMING_SNAKE_CASE     =       load_tf_weights_in_convbert(SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE       ,						SCREAMING_SNAKE_CASE )
			model.save_pretrained(SCREAMING_SNAKE_CASE )

			SCREAMING_SNAKE_CASE     =       TFConvBertModel.from_pretrained(SCREAMING_SNAKE_CASE       ,						from_pt=SCREAMING_SNAKE_CASE )
			tf_model.save_pretrained(SCREAMING_SNAKE_CASE )


if __name__ == "__main__":
		__A    :				str    						=	argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    """--tf_checkpoint_path""", default=None, type=str, required=True, help="""Path to the TensorFlow checkpoint path."""
		)
		parser.add_argument(
		    """--convbert_config_file""",
		    default=None,
		    type=str,
		    required=True,
		    help=(
		        """The config json file corresponding to the pre-trained ConvBERT model. \n"""
		        """This specifies the model architecture."""
		    ),
		)
		parser.add_argument(
		    """--pytorch_dump_path""", default=None, type=str, required=True, help="""Path to the output PyTorch model."""
		)
		__A    :				List[Any]    						=	parser.parse_args()
		convert_orig_tfa_checkpoint_to_pytorch(args.tf_checkpoint_path, args.convbert_config_file, args.pytorch_dump_path)






