code: def test_saved_model_creation_extended(self):
      (
          config,
          inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
      config.output_hidden_states = True
      config.output_attentions = True
  
      if hasattr(config, "use_cache"):
          config.use_cache = True
  
      encoder_seq_length = getattr(
          self.model_tester,
          "encoder_seq_length",
          self.model_tester.seq_length,
      )
      encoder_key_length = getattr(
          self.model_tester, "key_length", encoder_seq_length
      )
  
      for model_class in self.all_model_classes:
          class_inputs_dict = self._prepare_for_class(
              inputs_dict, model_class
          )
          model = model_class(config)
          num_out = len(model(class_inputs_dict))
  
          with tempfile.TemporaryDirectory() as tmpdirname:
              model.save_pretrained(tmpdirname, saved_model=True)
              saved_model_dir = os.path.join(
                  tmpdirname, "saved_model", "1"
              )
              model = tf.keras.models.load_model(saved_model_dir)
              outputs = model(class_inputs_dict)
              language_hidden_states = outputs["language_hidden_states"]
              vision_hidden_states = outputs["vision_hidden_states"]
              language_attentions = outputs["language_attentions"]
              vision_attentions = outputs["vision_attentions"]
              cross_encoder_attentions = outputs[
                  "cross_encoder_attentions"
              ]
  
              self.assertEqual(len(outputs), num_out)
  
              self.assertEqual(
                  len(language_hidden_states),
                  self.model_tester.num_hidden_layers["language"] + 1,
              )
              self.assertEqual(
                  len(vision_hidden_states),
                  self.model_tester.num_hidden_layers["vision"] + 1,
              )
  
              seq_length = self.model_tester.seq_length
              num_visual_features = (
                  self.model_tester.num_visual_features
              )
  
              self.assertListEqual(
                  list(language_hidden_states[0].shape[-2:]),
                  [seq_length, self.model_tester.hidden_size],
              )
              self.assertListEqual(
                  list(vision_hidden_states[0].shape[-2:]),
                  [num_visual_features, self.model_tester.hidden_size],
              )
  
              self.assertEqual(
                  len(language_attentions),
                  self.model_tester.num_hidden_layers["language"],
              )
              self.assertEqual(
                  len(vision_attentions),
                  self.model_tester.num_hidden_layers["vision"],
              )
              self.assertEqual(
                  len(cross_encoder_attentions),
                  self.model_tester.num_hidden_layers["cross_encoder"],
              )
  
              attentions = [
                  language_attentions,
                  vision_attentions,
                  cross_encoder_attentions,
              ]
              attention_shapes = [
                  [
                      self.model_tester.num_attention_heads,
                      encoder_seq_length,
                      encoder_key_length,
                  ],
                  [
                      self.model_tester.num_attention_heads,
                      self.model_tester.num_visual_features,
                      self.model_tester.num_visual_features,
                  ],
                  [
                      self.model_tester.num_attention_heads,
                      encoder_key_length,
                      self.model_tester.num_visual_features,
                  ],
              ]
  
              for attention, attention_shape in zip(
                  attentions, attention_shapes
              ):
                  self.assertListEqual(
                      list(attention[0].shape[-3:]), attention_shape
                  )
  
imports: import os
  import tempfile
  import unittest
  import numpy
  from transformers import LxmertConfig, is_tf_available
  from transformers.testing_utils import require_tf, slow, tooslow
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
label_desc: Use image node_id 13 for calling the TFLxmertModelTest obj's underlying member method code with example usage: obj.test_saved_model_creation_extended() without return types