code: def test_save_load_after_resize_token_embeddings(self):
      # Custom version of this test to ensure "end of sequence" tokens are present throughout
      if not self.test_resize_embeddings:
          return
      (
          config,
          original_inputs_dict,
      ) = self.model_tester.prepare_config_and_inputs_for_common()
      for model_class in self.all_model_classes:
          # create a model with resized (expended) embeddings
          new_tokens_size = 10
          old_total_size = config.vocab_size
          new_total_size = old_total_size + new_tokens_size
          model = model_class(
              config=copy.deepcopy(config)
          )  # `resize_token_embeddings` mutates `config`
          model.build_in_name_scope()
          model.resize_token_embeddings(new_total_size)
  
          # fetch the output for an input exclusively made of new members of the vocabulary
          inputs_dict = copy.deepcopy(original_inputs_dict)
          ids_feat_name = None
          if "input_ids" in inputs_dict:
              ids_feat_name = "input_ids"
          elif "decoder_input_ids" in inputs_dict:
              ids_feat_name = "decoder_input_ids"
          else:
              assert (
                  False
              ), "No input ids feature found in the inputs dict"
  
          new_vocab_input_ids = ids_tensor(
              inputs_dict[ids_feat_name].shape, new_tokens_size
          )
          new_vocab_input_ids += old_total_size
  
          # Replace last id with EOS token
          new_vocab_input_ids = new_vocab_input_ids[:, :-1]
          new_vocab_input_ids = tf.concat(
              [
                  new_vocab_input_ids,
                  tf.ones(
                      (tf.shape(new_vocab_input_ids)[0], 1),
                      dtype=tf.int32,
                  )
                  * 2,
              ],
              axis=1,
          )
  
          inputs_dict[ids_feat_name] = new_vocab_input_ids
          if "input_ids" in inputs_dict:
              inputs_dict["input_ids"] = new_vocab_input_ids
          if "decoder_input_ids" in inputs_dict:
              inputs_dict["decoder_input_ids"] = new_vocab_input_ids
          prepared_inputs = self._prepare_for_class(
              inputs_dict, model_class
          )
          outputs = model(**prepared_inputs)
  
          # save and load the model
          with tempfile.TemporaryDirectory() as tmpdirname:
              model.save_pretrained(tmpdirname, saved_model=False)
              model = model_class.from_pretrained(tmpdirname)
              restored_model_outputs = model(**prepared_inputs)
  
              # check that the output for the restored model is the same
              self.assert_outputs_same(restored_model_outputs, outputs)
  
imports: from __future__ import annotations
  import copy
  import tempfile
  import unittest
  import numpy
  from transformers import BartConfig, BartTokenizer, is_tf_available
  from transformers.testing_utils import require_tf, slow
  from transformers.utils import cached_property
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
  from ...utils.test_modeling_tf_core import TFCoreModelTesterMixin
label_desc: Use image node_id 7 for calling the TFBartModelTest obj's underlying member method code with example usage: obj.test_save_load_after_resize_token_embeddings() without return types