code: def ensure_tb_summary_proto(summary):
      """Ensures summary is TensorBoard Summary proto.
  
      TB v1 summary API returns TF Summary proto. To make test for v1 and
      v2 API congruent, one can use this API to convert result of v1 API
      to TB Summary proto.
      """
      if isinstance(summary, summary_pb2.Summary):
          return summary
  
      return summary_pb2.Summary.FromString(summary.SerializeToString())
  
imports: import threading
  import tensorflow
  from tensorboard.compat.proto import event_pb2
  from tensorboard.compat.proto import graph_pb2
  from tensorboard.compat.proto import meta_graph_pb2
  from tensorboard.compat.proto import summary_pb2
  from tensorboard.util import tb_logging
label_desc: Use image node_id 1 for calling a global function with example usage: ensure_tb_summary_proto(summary) and returns: summary_pb2, summary