code: def float_to_categorical(
      labels: np.ndarray, nb_classes: Optional[int] = None
  ):
      """
      Convert an array of floating point labels to binary class matrix.
  
      :param labels: An array of floating point labels of shape `(nb_samples,)`
      :param nb_classes: The number of classes (possible labels)
      :return: A binary matrix representation of `labels` in the shape `(nb_samples, nb_classes)`
      :rtype: `np.ndarray`
      """
      labels = np.array(labels)
      unique = np.unique(labels)
      unique.sort()
      indexes = [np.where(unique == value)[0] for value in labels]
      if nb_classes is None:
          nb_classes = len(unique)
      categorical = np.zeros(
          (labels.shape[0], nb_classes), dtype=np.float32
      )
      categorical[np.arange(labels.shape[0]), np.squeeze(indexes)] = 1
      return categorical
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  import os
  import shutil
  import sys
  import tarfile
  import warnings
  import zipfile
  from functools import wraps
  from inspect import signature
  from typing import TYPE_CHECKING, Callable, List, Dict, Optional, Tuple, Union
  import numpy
  import six
  from scipy.special import gammainc
  from tqdm.auto import tqdm
  from art import config
label_desc: Use image node_id 11 for calling a global function with example usage: float_to_categorical(labels, nb_classes) and returns: categorical