
"""simple docstring"""
import argparse

import torch

from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert
from transformers.utils import logging


logging.set_verbosity_info()





def    _lowerCAmelCase    (     lowerCamelCase__							:							Any,						lowerCamelCase__							:							Dict,						lowerCamelCase__							:							List[str]				)  ->    List[str]:
  # Initialise PyTorch model
  _SCREAMING_SNAKE_CASE   :				Tuple							    = LxmertConfig.from_json_file(lowerCamelCase__				)
  print(f'''Building PyTorch model from configuration: {config}'''				)
  _SCREAMING_SNAKE_CASE   :				Optional[int]							    = LxmertForPreTraining(lowerCamelCase__				)

  # Load weights from tf checkpoint
  load_tf_weights_in_lxmert(lowerCamelCase__,						lowerCamelCase__,						lowerCamelCase__				)

  # Save pytorch-model
  print(f'''Save PyTorch model to {pytorch_dump_path}'''				)
  torch.save(model.state_dict(),						lowerCamelCase__				)


if __name__ == "__main__":
      lowercase_       :						Union[str, Any]     					=	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(
          '''--config_file''',
          default=None,
          type=str,
          required=True,
          help='''The config json file corresponding to the pre-trained model. \nThis specifies the model architecture.''',
      )
      parser.add_argument(
          '''--pytorch_dump_path''', default=None, type=str, required=True, help='''Path to the output PyTorch model.'''
      )
      lowercase_       :						Union[str, Any]     					=	parser.parse_args()
      convert_tf_checkpoint_to_pytorch(args.tf_checkpoint_path, args.config_file, args.pytorch_dump_path)





"""simple docstring"""
import fire

from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer





def    _lowerCAmelCase    (     lowerCamelCase__							:							str,						lowerCamelCase__							:							str,						**lowerCamelCase__							:							Optional[Any]				)  ->    Union[str, Any]:
  _SCREAMING_SNAKE_CASE   :				Dict							    = AutoConfig.from_pretrained(lowerCamelCase__,						**lowerCamelCase__				)
  _SCREAMING_SNAKE_CASE   :				List[str]							    = AutoModelForSeqaSeqLM.from_config(lowerCamelCase__				)
  model.save_pretrained(lowerCamelCase__				)
  AutoTokenizer.from_pretrained(lowerCamelCase__				).save_pretrained(lowerCamelCase__				)
  return model


if __name__ == "__main__":
      fire.Fire(save_randomly_initialized_version)



