code: def scalar_summary(tag, scalar):
      
      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)])
docs: 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.