code: def scalar_summary(tag, scalar):
      """Outputs a `Summary` protocol buffer containing a single scalar value.
      The generated Summary has a Tensor.proto containing the input Tensor.
      Adapted from the TensorFlow function `scalar()` at
      https://github.com/tensorflow/tensorflow/blob/r1.6/tensorflow/python/summary/summary.py
  
      Parameters
      ----------
        tag : str
            A name for the generated summary. Will also serve as the series name in TensorBoard.
        scalar : int, MXNet `NDArray`, or `numpy.ndarray`
            A scalar value or an ndarray of shape (1,).
  
      Returns
      -------
        A `Summary` protobuf of the `scalar` value.
  
      Raises
      ------
        ValueError: If the scalar has the wrong shape or type.
      """
      tag = _clean_tag(tag)
      scalar = _make_numpy_array(scalar)
      assert scalar.squeeze().ndim == 0, "scalar should be 0D"
      scalar = float(scalar)
      return Summary(
          value=[Summary.Value(tag=tag, simple_value=scalar)]
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  import io
  import wave
  import struct
  import json
  import re
  import numpy
  from mxnet.ndarray import NDArray
  from mxnet.symbol import Symbol
  from mxnet.gluon import HybridBlock
  from .proto.summary_pb2 import Summary
  from .proto.summary_pb2 import HistogramProto
  from .proto.summary_pb2 import SummaryMetadata
  from .proto.tensor_pb2 import TensorProto
  from .proto.tensor_shape_pb2 import TensorShapeProto
  from .proto.plugin_pr_curve_pb2 import PrCurvePluginData
  from .proto.node_def_pb2 import NodeDef
  from .proto.graph_pb2 import GraphDef
  from .proto.attr_value_pb2 import AttrValue
  from .proto.versions_pb2 import VersionDef
  from .utils import _make_numpy_array, _prepare_image
label_desc: Use image node_id 2 for calling a global function with example usage: scalar_summary(tag, scalar) and returns: Summary