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)
  
              if self.is_encoder_decoder:
                  output_hidden_states = outputs[
                      "encoder_hidden_states"
                  ]
                  output_attentions = outputs["encoder_attentions"]
              else:
                  output_hidden_states = outputs["hidden_states"]
                  output_attentions = outputs["attentions"]
  
              self.assertEqual(len(outputs), num_out)
  
              expected_num_layers = getattr(
                  self.model_tester,
                  "expected_num_hidden_layers",
                  self.model_tester.num_hidden_layers + 1,
              )
  
              self.assertEqual(
                  len(output_hidden_states), expected_num_layers
              )
              self.assertListEqual(
                  list(output_hidden_states[0].shape[-2:]),
                  [
                      self.model_tester.seq_length,
                      self.model_tester.hidden_size,
                  ],
              )
  
              self.assertEqual(
                  len(output_attentions),
                  self.model_tester.num_hidden_layers,
              )
              self.assertListEqual(
                  list(output_attentions[0].shape[-3:]),
                  [
                      self.model_tester.num_attention_heads / 2,
                      encoder_seq_length,
                      encoder_key_length,
                  ],
              )
  
imports: from __future__ import annotations
  import os
  import tempfile
  import unittest
  from transformers import ConvBertConfig, is_tf_available
  from transformers.testing_utils import require_tf, slow
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 9 for calling the TFConvBertModelTest obj's underlying member method code with example usage: obj.test_saved_model_creation_extended() without return types