code: def latent_from_labels(
      Z: tf.Tensor, labels: TensorType
  ) -> TensorType:
      """
      Converts a tensor of labels into a tensor of the latent space values of those labels.
  
      :param Z: Z is a tensor whose entries are the latent space values of the relevant label
          i.e. Z[3] is the value of label 3.
          [num_labels, label_dim=1]
      :param labels: labels is a vector.  Each entry corresponds to one of the points in the data,
          X.  The value is an integer that specifies which category that point belongs to.  Note
          that the value will likely be stored as a float (or whatever the rest of the data is)
          even though it represents an integer value.
      :return: [..., N, D + label_dim]
      """
      indices = tf.cast(labels, default_int())  # [..., N]
      return tf.gather(Z, indices)
  
file_path: GPflow/gpflow/kernels/categorical.py
imports: from typing import Any, Optional
  import numpy
  import tensorflow
  from ..None import default_int, set_trainable
  from ..base import Parameter, TensorType
  from .None import Kernel
label_desc: Use image node_id 1 for calling a global function with example usage: latent_from_labels(Z, labels) and returns: tf