code: def label_to_one_hot(x, labels):
      """
      One-hot encodes the integer array `x` according to the given `labels`.
  
      :param x: a np.array of integers. Each value must be contained in `labels`.
      :param labels: list/tuple/np.array of labels.
      :return: an array of shape `x.shape + (len(labels), )`
      """
      if not isinstance(labels, (list, tuple, np.ndarray)):
          raise ValueError("labels must be list, tuple, or np.ndarray")
      if not np.all(np.in1d(x, labels)):
          raise ValueError(
              "All values in x must be contained in labels"
          )
      depth = len(labels)
      x = np.array(x).astype(int)
      out = x.copy()
      for i, label in enumerate(labels):
          out[x == label] = i
  
      return one_hot(out, depth)
  
imports: import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: label_to_one_hot(x, labels) and returns: one_hot