code: def test_restore_nodes_with_different_number_of_serialized_to_tensors(
      self,
  ):
      class MyTrackableA(base.Trackable):
          def __init__(self):
              self.a = variables.Variable(5.0)
  
          def _restore_from_tensors(self, restored_tensors):
              return self.a.assign(restored_tensors["a"])
  
          def _serialize_to_tensors(self):
              return {"a": self.a}
  
      class MyTrackableAandB(base.Trackable):
          def __init__(self):
              self.a = variables.Variable(5.0)
              self.b = variables.Variable(6.0)
  
          def _restore_from_tensors(self, restored_tensors):
              return control_flow_ops.group(
                  self.a.assign(restored_tensors["a"]),
                  self.b.assign(restored_tensors["b"]),
              )
  
          def _serialize_to_tensors(self):
              return {"a": self.a, "b": self.b}
  
      root = MyTrackableA()
      root_ckpt = trackable_utils.Checkpoint(root=root)
      root_save_path = root_ckpt.save(
          os.path.join(self.get_temp_dir(), "root_ckpt")
      )
  
      root2 = MyTrackableAandB()
  
      with self.assertRaisesRegex(
          ValueError,
          "Size for serialized_tensors for Trackable: 2 did not match size for "
          "serialized_tensors for checkpoint: 1.",
      ):
          restore.restore_nodes(root_save_path, {0: root2})
  
      root = MyTrackableAandB()
      root_ckpt = trackable_utils.Checkpoint(root=root)
      root_save_path = root_ckpt.save(
          os.path.join(self.get_temp_dir(), "root_ckpt")
      )
  
      root2 = MyTrackableA()
  
      with self.assertRaisesRegex(
          ValueError,
          "Size for serialized_tensors for Trackable: 1 did not match size for "
          "serialized_tensors for checkpoint: 2.",
      ):
          restore.restore_nodes(root_save_path, {0: root2})
  
file_path: tensorflow/tensorflow/python/checkpoint/restore_test.py
imports: import os
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.checkpoint import restore
  from tensorflow.python.eager import test
  from tensorflow.python.module import module
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.trackable import autotrackable
  from tensorflow.python.trackable import base
  from tensorflow.python.training.saving import saveable_object
label_desc: Use image node_id 5 for calling the ExtractSaveablenameTest obj's underlying member method code with example usage: obj.test_restore_nodes_with_different_number_of_serialized_to_tensors() and returns: self, dict, control_flow_ops, dict