code: def pb(name, data, display_name=None, description=None):
      """Create a legacy scalar summary protobuf.
  
      Arguments:
        name: A unique name for the generated summary, including any desired
          name scopes.
        data: A rank-0 `np.array` or array-like form (so raw `int`s and
          `float`s are fine, too).
        display_name: Optional name for this summary in TensorBoard, as a
          `str`. Defaults to `name`.
        description: Optional long-form description for this summary, as a
          `str`. Markdown is supported. Defaults to empty.
  
      Returns:
        A `tf.Summary` protobuf object.
      """
      # TODO(nickfelt): remove on-demand imports once dep situation is fixed.
      import tensorflow.compat.v1 as tf
  
      data = np.array(data)
      if data.shape != ():
          raise ValueError(
              "Expected scalar shape for data, saw shape: %s."
              % data.shape
          )
      if data.dtype.kind not in (
          "b",
          "i",
          "u",
          "f",
      ):  # bool, int, uint, float
          raise ValueError(
              "Cast %s to float is not supported" % data.dtype.name
          )
      tensor = tf.make_tensor_proto(data.astype(np.float32))
  
      if display_name is None:
          display_name = name
      summary_metadata = metadata.create_summary_metadata(
          display_name=display_name, description=description
      )
      tf_summary_metadata = tf.SummaryMetadata.FromString(
          summary_metadata.SerializeToString()
      )
      summary = tf.Summary()
      summary.value.add(
          tag="%s/scalar_summary" % name,
          metadata=tf_summary_metadata,
          tensor=tensor,
      )
      return summary
  
imports: import numpy
  from tensorboard.plugins.scalar import metadata
  from tensorboard.plugins.scalar import summary_v2
label_desc: Use image node_id 2 for calling a global function with example usage: pb(name, data, display_name, description) and returns: summary