class_docstr: Tests for `migrate_event`.
class_docstr_tok: ["Tests","for","`","migrate_event","`","."]
code: def test_graph_def(self):
      # Create a `GraphDef` and write it to disk as an event.
      logdir = self.get_temp_dir()
      writer = test_util.FileWriter(logdir)
      graph_def = graph_pb2.GraphDef()
      graph_def.node.add(name="alice", op="Person")
      graph_def.node.add(name="bob", op="Person")
      graph_def.node.add(
          name="friendship", op="Friendship", input=["alice", "bob"]
      )
      writer.add_graph(graph=None, graph_def=graph_def, global_step=123)
      writer.flush()
  
      # Read in the `Event` containing the written `graph_def`.
      files = os.listdir(logdir)
      self.assertLen(files, 1)
      event_file = os.path.join(logdir, files[0])
      self.assertIn("tfevents", event_file)
      loader = event_file_loader.RawEventFileLoader(event_file)
      events = [event_pb2.Event.FromString(x) for x in loader.Load()]
      self.assertLen(events, 2)
      self.assertEqual(events[0].WhichOneof("what"), "file_version")
      self.assertEqual(events[1].WhichOneof("what"), "graph_def")
      old_event = events[1]
  
      new_events = self._migrate_event(old_event)
      self.assertLen(new_events, 2)
      self.assertIs(new_events[0], old_event)
      new_event = new_events[1]
  
      self.assertEqual(new_event.WhichOneof("what"), "summary")
      self.assertLen(new_event.summary.value, 1)
      tensor = tensor_util.make_ndarray(
          new_event.summary.value[0].tensor
      )
      self.assertEqual(
          new_event.summary.value[0].metadata.data_class,
          summary_pb2.DATA_CLASS_BLOB_SEQUENCE,
      )
      self.assertEqual(
          new_event.summary.value[0].metadata.plugin_data.plugin_name,
          graphs_metadata.PLUGIN_NAME,
      )
      self.assertEqual(tensor.shape, (1,))
      new_graph_def_bytes = tensor[0]
      self.assertIsInstance(new_graph_def_bytes, bytes)
      self.assertGreaterEqual(len(new_graph_def_bytes), 16)
      new_graph_def = graph_pb2.GraphDef.FromString(new_graph_def_bytes)
  
      self.assertProtoEquals(graph_def, new_graph_def)
  
imports: import os
  import numpy
  import tensorflow
  from tensorboard import dataclass_compat
  from tensorboard.backend.event_processing import event_file_loader
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.proto import graph_pb2
  from tensorboard.compat.proto import summary_pb2
  from tensorboard.plugins.audio import metadata
  from tensorboard.plugins.audio import summary
  from tensorboard.plugins.graph import metadata
  from tensorboard.plugins.histogram import metadata
  from tensorboard.plugins.histogram import summary
  from tensorboard.plugins.hparams import metadata
  from tensorboard.plugins.hparams import summary_v2
  from tensorboard.plugins.pr_curve import metadata
  from tensorboard.plugins.pr_curve import summary
  from tensorboard.plugins.scalar import metadata
  from tensorboard.plugins.scalar import summary
  from tensorboard.util import tensor_util
  from tensorboard.util import test_util
label_desc: Use image node_id 11 for calling the MigrateEventTest obj's underlying member method code with example usage: obj.test_graph_def() without return types