code: def scalar(name, data, step=None, description=None):
      """Write a scalar summary.
  
      See also `tf.summary.image`, `tf.summary.histogram`,
      `tf.summary.SummaryWriter`.
  
      Writes simple numeric values for later analysis in TensorBoard.  Writes go to
      the current default summary writer. Each summary point is associated with an
      integral `step` value. This enables the incremental logging of time series
      data.  A common usage of this API is to log loss during training to produce
      a loss curve.
  
      For example:
  
      ```python
      test_summary_writer = tf.summary.create_file_writer('test/logdir')
      with test_summary_writer.as_default():
          tf.summary.scalar('loss', 0.345, step=1)
          tf.summary.scalar('loss', 0.234, step=2)
          tf.summary.scalar('loss', 0.123, step=3)
      ```
  
      Multiple independent time series may be logged by giving each series a unique
      `name` value.
  
      See [Get started with
      TensorBoard](https://www.tensorflow.org/tensorboard/get_started)
      for more examples of effective usage of `tf.summary.scalar`.
  
      In general, this API expects that data points are logged with a monotonically
      increasing step value. Duplicate points for a single step or points logged out
      of order by step are not guaranteed to display as desired in TensorBoard.
  
      Arguments:
        name: A name for this summary. The summary tag used for TensorBoard will be
          this name prefixed by any active name scopes.
        data: A real numeric scalar value, convertible to a `float32` Tensor.
        step: Explicit `int64`-castable monotonic step value for this summary. If
          omitted, this defaults to `tf.summary.experimental.get_step()`, which must
          not be None.
        description: Optional long-form description for this summary, as a constant
          `str`. Markdown is supported. Defaults to empty.
  
      Returns:
        True on success, or false if no summary was written because no default
        summary writer was available.
  
      Raises:
        ValueError: if a default writer exists, but no step was provided and
          `tf.summary.experimental.get_step()` is None.
      """
      try:
          from tensorboard.summary.v2 import (
              scalar as scalar_v2,
          )  # pylint: disable=g-import-not-at-top, g-importing-member
      except ImportError as exc:
          raise TBNotInstalledError("tf.summary.scalar") from exc
      return scalar_v2(
          name=name, data=data, step=step, description=description
      )
  
file_path: tensorflow/tensorflow/python/summary/tb_summary.py
imports: from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 4 for calling a global function with example usage: scalar(name, data, step, description) and returns: scalar_v2