class_docstr: Slot type which can be used to branch conversations based on its value.
class_docstr_tok: ["Slot","type","which","can","be","used","to","branch","conversations","based","on","its","value","."]
code: def _as_feature(self) -> List[float]:
      r = [0.0] * self.feature_dimensionality()
  
      # Return the zero-filled array if the slot is unset (i.e. set to None).
      # Conceptually, this is similar to the case when the featurisation process
      # fails, hence the returned features here are the same as for that case.
      if self.value is None:
          return r
  
      try:
          for i, v in enumerate(self.values):
              if v == str(self.value).lower():
                  r[i] = 1.0
                  break
          else:
              if (
                  rasa.shared.core.constants.DEFAULT_CATEGORICAL_SLOT_VALUE
                  in self.values
              ):
                  i = self.values.index(
                      rasa.shared.core.constants.DEFAULT_CATEGORICAL_SLOT_VALUE
                  )
                  r[i] = 1.0
              else:
                  rasa.shared.utils.io.raise_warning(
                      f"Categorical slot '{self.name}' is set to a value "
                      f"('{self.value}') "
                      "that is not specified in the domain. "
                      "Value will be ignored and the slot will "
                      "behave as if no value is set. "
                      "Make sure to add all values a categorical "
                      "slot should store to the domain."
                  )
      except (TypeError, ValueError):
          logger.exception("Failed to featurize categorical slot.")
          return r
      return r
  
imports: import logging
  from abc import ABC, abstractmethod
  from typing import Any, Dict, List, Optional, Text, Type
  import rasa.shared.core.constants
  from rasa.shared.exceptions import RasaException
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  from rasa.shared.constants import DOCS_URL_SLOTS
label_desc: Use image node_id 4 for calling the CategoricalSlot obj's underlying member method code with example usage: obj._as_feature() and returns: r, r, r