class_docstr: Abstract custom Keras model.
  
   This model overwrites the following methods:
  - train_step
  - test_step
  - predict_step
  - save
  - load
  Cannot be used as tf.keras.Model.
class_docstr_tok: ["Abstract","custom","Keras","model",".","This","model","overwrites","the","following","methods",":","-","train_step","-","test_step","-","predict_step","-","save","-","load","Can","not","be","used","as","tf.keras.Model","."]
docstr: Convert input batch tensors into batch data format.
  
  Batch contains any number of batch data. The order is equal to the
  key-value pairs in session data. As sparse data were converted into (indices,
  data, shape) before, this method converts them into sparse tensors. Dense
  data is kept.
docstr_tok: ["Convert","input","batch","tensors","into","batch","data","format",".","Batch","contains","any","number","of","batch","data",".","The","order","is","equal","to","the","key-value","pairs","in","session","data",".","As","sparse","data","were","converted","into","(","indices",",","data",",","shape",")","before",",","this","method","converts","them","into","sparse","tensors",".","Dense","data","is","kept","."]
code: def batch_to_model_data_format(
      batch: MaybeNestedBatchData,
      data_signature: Dict[Text, Dict[Text, List[FeatureSignature]]],
  ) -> Dict[Text, Dict[Text, List[tf.Tensor]]]:
      """Convert input batch tensors into batch data format.
  
      Batch contains any number of batch data. The order is equal to the
      key-value pairs in session data. As sparse data were converted into (indices,
      data, shape) before, this method converts them into sparse tensors. Dense
      data is kept.
      """
      # during training batch is a tuple of input and target data
      # as our target data is inside the input data, we are just interested in the
      # input data
      unpacked_batch = (
          batch[0] if isinstance(batch[0], Tuple) else batch
      )
  
      batch_data: Dict[Text, Dict[Text, List[tf.Tensor]]] = defaultdict(
          lambda: defaultdict(list)
      )
  
      idx = 0
      for key, values in data_signature.items():
          for sub_key, signature in values.items():
              for (
                  is_sparse,
                  feature_dimension,
                  number_of_dimensions,
              ) in signature:
                  # we converted all 4D features to 3D features before
                  number_of_dimensions = (
                      number_of_dimensions
                      if number_of_dimensions != 4
                      else 3
                  )
                  if is_sparse:
                      tensor, idx = RasaModel._convert_sparse_features(
                          unpacked_batch,
                          feature_dimension,
                          idx,
                          number_of_dimensions,
                      )
                  else:
                      tensor, idx = RasaModel._convert_dense_features(
                          unpacked_batch,
                          feature_dimension,
                          idx,
                          number_of_dimensions,
                      )
                  batch_data[key][sub_key].append(tensor)
  
      return batch_data
  
imports: import time
  import random
  import tensorflow
  import numpy
  import logging
  import os
  from collections import defaultdict
  from typing import List, Text, Dict, Tuple, Union, Optional, Any, TYPE_CHECKING
  from keras.utils import tf_utils
  from keras import Model
  from rasa.shared.constants import DIAGNOSTIC_DATA
  from rasa.utils.tensorflow.constants import LABEL, IDS, INTENT_CLASSIFICATION, SENTENCE, SEQUENCE_LENGTH, RANDOM_SEED, EMBEDDING_DIMENSION, REGULARIZATION_CONSTANT, SIMILARITY_TYPE, CONNECTION_DENSITY, NUM_NEG, LOSS_TYPE, MAX_POS_SIM, MAX_NEG_SIM, USE_MAX_NEG_SIM, NEGATIVE_MARGIN_SCALE, SCALE_LOSS, LEARNING_RATE, CONSTRAIN_SIMILARITIES, MODEL_CONFIDENCE, RUN_EAGERLY
  from rasa.utils.tensorflow.model_data import RasaModelData, FeatureSignature, FeatureArray
  import rasa.utils.train_utils
  from rasa.utils.tensorflow import layers
  from rasa.utils.tensorflow import rasa_layers
  from rasa.utils.tensorflow.data_generator import RasaDataGenerator, RasaBatchDataGenerator
  from rasa.shared.nlu.constants import TEXT
  from rasa.shared.exceptions import RasaException
  from rasa.utils.tensorflow.types import BatchData, MaybeNestedBatchData
label_desc: Use image node_id 17 for calling the RasaModel obj's underlying member method code with example usage: obj.batch_to_model_data_format(batch, data_signature) and returns: batch_data