class_docstr: Follows TED's model architecture from https://arxiv.org/abs/1910.00486.
  
  However, it has been re-purposed to predict multiple
  labels (intents) instead of a single label (action).
class_docstr_tok: ["Follows","TED","'s","model","architecture","from","https",":","\/\/arxiv.org\/abs\/1910.00486",".","However",",","it","has","been","re-purposed","to","predict","multiple","labels","(","intents",")","instead","of","a","single","label","(","action",")","."]
code: def _get_labels_embed(
      label_ids: tf.Tensor, all_labels_embed: tf.Tensor
  ) -> tf.Tensor:
      # instead of processing labels again, gather embeddings from
      # all_labels_embed using label ids
  
      indices = tf.cast(label_ids[:, :, 0], tf.int32)
  
      # Find padding indices. They should have a value equal to `LABEL_PAD_ID`
      padding_indices = tf.where(tf.equal(indices, LABEL_PAD_ID))
  
      # Create a tensor of values with sign opposite to `LABEL_PAD_ID` which
      # will serve as updates to original `indices`
      updates_to_indices = (
          tf.ones((tf.shape(padding_indices)[0]), dtype=tf.int32)
          * -1
          * LABEL_PAD_ID
      )
  
      # Add the updates tensor to indices with padding.
      # So, effectively all indices with `LABEL_PAD_ID=-1`
      # become 0 because updates contain 1s.
      # This is fine because we don't change the original non-padding label
      # indices but only make the padding indices 'compatible'
      # for the `tf.gather` op below.
      indices_to_gather = tf.cast(
          tf.tensor_scatter_nd_add(
              indices, padding_indices, updates_to_indices
          ),
          tf.int32,
      )
  
      labels_embed = tf.gather(all_labels_embed, indices_to_gather)
  
      return labels_embed
  
imports: import dataclasses
  import logging
  from pathlib import Path
  from typing import Any, List, Optional, Text, Dict, Type, Union
  import numpy
  import tensorflow
  import rasa.utils.common
  from rasa.engine.graph import ExecutionContext
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.classifiers import LABEL_RANKING_LENGTH
  from rasa.shared.nlu.training_data.features import Features
  from rasa.shared.core.domain import Domain
  from rasa.shared.core.trackers import DialogueStateTracker
  from rasa.shared.core.constants import SLOTS, ACTIVE_LOOP, ACTION_UNLIKELY_INTENT_NAME
  from rasa.shared.core.events import UserUttered, ActionExecuted
  from rasa.shared.nlu.constants import INTENT, TEXT, ENTITIES, ACTION_NAME, SPLIT_ENTITIES_BY_COMMA, SPLIT_ENTITIES_BY_COMMA_DEFAULT_VALUE
  from rasa.nlu.extractors.extractor import EntityTagSpec
  from rasa.core.featurizers.precomputation import MessageContainerForCoreFeaturization
  from rasa.core.featurizers.tracker_featurizers import TrackerFeaturizer
  from rasa.core.featurizers.tracker_featurizers import IntentMaxHistoryTrackerFeaturizer
  from rasa.core.featurizers.single_state_featurizer import IntentTokenizerSingleStateFeaturizer
  from rasa.shared.core.generator import TrackerWithCachedStates
  from rasa.core.constants import DIALOGUE, POLICY_MAX_HISTORY, POLICY_PRIORITY, UNLIKELY_INTENT_POLICY_PRIORITY
  from rasa.core.policies.policy import PolicyPrediction
  from rasa.core.policies.ted_policy import LABEL_KEY, LABEL_SUB_KEY, TEDPolicy, TED, SEQUENCE_LENGTH, SEQUENCE, PREDICTION_FEATURES
  from rasa.utils import train_utils
  from rasa.utils.tensorflow.models import RasaModel
  from rasa.utils.tensorflow.constants import LABEL, DENSE_DIMENSION, ENCODING_DIMENSION, UNIDIRECTIONAL_ENCODER, TRANSFORMER_SIZE, NUM_TRANSFORMER_LAYERS, NUM_HEADS, BATCH_SIZES, BATCH_STRATEGY, EPOCHS, RANDOM_SEED, RANKING_LENGTH, LOSS_TYPE, SIMILARITY_TYPE, NUM_NEG, EVAL_NUM_EXAMPLES, EVAL_NUM_EPOCHS, REGULARIZATION_CONSTANT, SCALE_LOSS, EMBEDDING_DIMENSION, DROP_RATE_DIALOGUE, DROP_RATE_LABEL, DROP_RATE, DROP_RATE_ATTENTION, CONNECTION_DENSITY, KEY_RELATIVE_ATTENTION, VALUE_RELATIVE_ATTENTION, MAX_RELATIVE_POSITION, INNER, BALANCED, TENSORBOARD_LOG_DIR, TENSORBOARD_LOG_LEVEL, CHECKPOINT_MODEL, FEATURIZERS, ENTITY_RECOGNITION, IGNORE_INTENTS_LIST, BILOU_FLAG, LEARNING_RATE, CROSS_ENTROPY, SPARSE_INPUT_DROPOUT, DENSE_INPUT_DROPOUT, MASKED_LM, HIDDEN_LAYERS_SIZES, CONCAT_DIMENSION, TOLERANCE, LABEL_PAD_ID, POSITIVE_SCORES_KEY, NEGATIVE_SCORES_KEY, USE_GPU
  from rasa.utils.tensorflow import layers
  from rasa.utils.tensorflow.model_data import RasaModelData, FeatureArray, Data
  import rasa.utils.io
  from rasa.core.exceptions import RasaCoreException
  from rasa.shared.utils import common
label_desc: Use image node_id 3 for calling the IntentTED obj's underlying member method code with example usage: obj._get_labels_embed(label_ids, all_labels_embed) and returns: labels_embed