code: def convert_pt_checkpoint_to_tf(
      model_type,
      pytorch_checkpoint_path,
      config_file,
      tf_dump_path,
      compare_with_pt_model=False,
      use_cached_models=True,
  ):
      if model_type not in MODEL_CLASSES:
          raise ValueError(
              f"Unrecognized model type, should be one of {list(MODEL_CLASSES.keys())}."
          )
  
      (
          config_class,
          model_class,
          pt_model_class,
          aws_config_map,
      ) = MODEL_CLASSES[model_type]
  
      # Initialise TF model
      if config_file in aws_config_map:
          config_file = cached_file(
              config_file,
              CONFIG_NAME,
              force_download=not use_cached_models,
          )
      config = config_class.from_json_file(config_file)
      config.output_hidden_states = True
      config.output_attentions = True
      print(f"Building TensorFlow model from configuration: {config}")
      tf_model = model_class(config)
  
      # Load weights from tf checkpoint
      if pytorch_checkpoint_path in aws_config_map.keys():
          pytorch_checkpoint_path = cached_file(
              pytorch_checkpoint_path,
              WEIGHTS_NAME,
              force_download=not use_cached_models,
          )
      # Load PyTorch checkpoint in tf2 model:
      tf_model = load_pytorch_checkpoint_in_tf2_model(
          tf_model, pytorch_checkpoint_path
      )
  
      if compare_with_pt_model:
          tfo = tf_model(
              tf_model.dummy_inputs, training=False
          )  # build the network
  
          state_dict = torch.load(
              pytorch_checkpoint_path,
              map_location="cpu",
              weights_only=True,
          )
          pt_model = pt_model_class.from_pretrained(
              pretrained_model_name_or_path=None,
              config=config,
              state_dict=state_dict,
          )
  
          with torch.no_grad():
              pto = pt_model(**pt_model.dummy_inputs)
  
          np_pt = pto[0].numpy()
          np_tf = tfo[0].numpy()
          diff = np.amax(np.abs(np_pt - np_tf))
          print(
              f"Max absolute difference between models outputs {diff}"
          )
          assert (
              diff <= 2e-2
          ), f"Error, model absolute difference is >2e-2: {diff}"
  
      # Save pytorch-model
      print(f"Save TensorFlow model to {tf_dump_path}")
      tf_model.save_weights(tf_dump_path, save_format="h5")
  
imports: import argparse
  import os
  from .None import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST, DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST, DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST, ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP, FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST, LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP, OPENAI_GPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, T5_PRETRAINED_CONFIG_ARCHIVE_MAP, TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP, WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP, XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, BartConfig, BertConfig, CamembertConfig, CTRLConfig, DistilBertConfig, DPRConfig, ElectraConfig, FlaubertConfig, GPT2Config, LayoutLMConfig, LxmertConfig, OpenAIGPTConfig, RobertaConfig, T5Config, TFAlbertForPreTraining, TFBartForConditionalGeneration, TFBartForSequenceClassification, TFBertForPreTraining, TFBertForQuestionAnswering, TFBertForSequenceClassification, TFCamembertForMaskedLM, TFCTRLLMHeadModel, TFDistilBertForMaskedLM, TFDistilBertForQuestionAnswering, TFDPRContextEncoder, TFDPRQuestionEncoder, TFDPRReader, TFElectraForPreTraining, TFFlaubertWithLMHeadModel, TFGPT2LMHeadModel, TFLayoutLMForMaskedLM, TFLxmertForPreTraining, TFLxmertVisualFeatureEncoder, TFOpenAIGPTLMHeadModel, TFRobertaForCausalLM, TFRobertaForMaskedLM, TFRobertaForSequenceClassification, TFT5ForConditionalGeneration, TFTransfoXLLMHeadModel, TFWav2Vec2Model, TFXLMRobertaForMaskedLM, TFXLMWithLMHeadModel, TFXLNetLMHeadModel, TransfoXLConfig, Wav2Vec2Config, Wav2Vec2Model, XLMConfig, XLMRobertaConfig, XLNetConfig, is_torch_available, load_pytorch_checkpoint_in_tf2_model
  from .utils import CONFIG_NAME, WEIGHTS_NAME, cached_file, logging
label_desc: Use image node_id 1 for calling a global function with example usage: convert_pt_checkpoint_to_tf(model_type, pytorch_checkpoint_path, config_file, tf_dump_path, compare_with_pt_model, use_cached_models) without return types