code: def test_serialization(tmpdir):
      g1 = graph_item.GraphItem(graph=ops.Graph())
      with g1.as_default():
          model = model_keras_dense_and_sparse()
          trainable_variables = model.trainable_variables
          optimizer = adagrad.Adagrad()
          grads = optimizer.get_gradients(
              model.outputs[0], trainable_variables
          )
          optimizer.apply_gradients(zip(grads, trainable_variables))
          g1.prepare()
      path = tmpdir.join("tmp_item.pb")
      g1.serialize(path)
      g2 = graph_item.GraphItem.deserialize(path)
  
      def compare(g1, g2):
          gd1 = g1.graph.as_graph_def()
          gd2 = g2.graph.as_graph_def()
          assert gd1 is not gd2
          assert gd1 == gd2
          d1 = {n.name: n for n in gd1.node}
          d2 = {n.name: n for n in gd2.node}
          assert d1 == d2
          assert g1._grad_target_pairs == g2._grad_target_pairs
          assert g1.info == g2.info
  
      compare(g1, g2)
  
file_path: autodist/tests/test_graph_item.py
imports: import numpy
  import pytest
  import tensorflow
  from tensorflow.python import ops
  from tensorflow.python.keras.optimizer_v2 import adadelta
  from tensorflow.python.keras.optimizer_v2 import adagrad
  from tensorflow.python.keras.optimizer_v2 import adam
  from tensorflow.python.keras.optimizer_v2 import adamax
  from tensorflow.python.keras.optimizer_v2 import ftrl
  from tensorflow.python.keras.optimizer_v2 import gradient_descent
  from tensorflow.python.keras.optimizer_v2 import nadam
  from tensorflow.python.keras.optimizer_v2 import rmsprop
  from tensorflow.python.training.training_util import get_or_create_global_step
  from autodist import graph_item
  from autodist.kernel.common.op_info import UPDATE_OP_VAR_POS
label_desc: Use image node_id 5 for calling a global function with example usage: test_serialization(tmpdir) without return types