code: def scalar_concat(tensor, scalar):
      """Concatenates a scalar to the last dimension of a tensor.
  
      Args:
        tensor: A `Tensor`.
        scalar: a scalar `Tensor` to concatenate to tensor `tensor`.
  
      Returns:
        A `Tensor`. If `tensor` has shape [...,N], the result R has shape
        [...,N+1] and R[...,N] = scalar.
  
      Raises:
        ValueError: If `tensor` is a scalar `Tensor`.
      """
      ndims = tensor.shape.ndims
      if ndims < 1:
          raise ValueError(
              "`tensor` must have number of dimensions >= 1."
          )
      shape = tf.shape(tensor)
      return tf.concat(
          [
              tensor,
              tf.ones([shape[i] for i in range(ndims - 1)] + [1])
              * scalar,
          ],
          axis=ndims - 1,
      )
  
file_path: magenta/magenta/models/gansynth/lib/layers.py
imports: import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling a global function with example usage: scalar_concat(tensor, scalar) and returns: tf