code: def scalar_pb(tag, data, description=None):
    
    arr = np.array(data)
    if arr.shape != ():
      raise ValueError('Expected scalar shape for tensor, got shape: %s.'
                       % arr.shape)
    if arr.dtype.kind not in ('b', 'i', 'u', 'f'):  # bool, int, uint, float
      raise ValueError('Cast %s to float is not supported' % arr.dtype.name)
    tensor_proto = tensor_util.make_tensor_proto(arr.astype(np.float32))
    summary_metadata = metadata.create_summary_metadata(
        display_name=None, description=description)
    summary = summary_pb2.Summary()
    summary.value.add(tag=tag,
                      metadata=summary_metadata,
                      tensor=tensor_proto)
    return summary
docs: Create a scalar summary_pb2.Summary protobuf.
  
    Arguments:
      tag: String tag for the summary.
      data: A 0-dimensional `np.array` or a compatible python number type.
      description: Optional long-form description for this summary, as a
        `str`. Markdown is supported. Defaults to empty.
  
    Raises:
      ValueError: If the type or shape of the data is unsupported.
  
    Returns:
      A `summary_pb2.Summary` protobuf object.