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: Implements bulk inferencing through the model.
  
  Args:
      model_data: Input data to be fed to the model.
      batch_size: Size of batches that the generator should create.
      output_keys_expected: Keys which are expected in the output.
          The output should be filtered to have only these keys before
          merging it with the output across all batches.
  
  Returns:
      Model outputs corresponding to the inputs fed.
docstr_tok: ["Implements","bulk","inferencing","through","the","model",".","Args",":","model_data",":","Input","data","to","be","fed","to","the","model",".","batch_size",":","Size","of","batches","that","the","generator","should","create",".","output_keys_expected",":","Keys","which","are","expected","in","the","output",".","The","output","should","be","filtered","to","have","only","these","keys","before","merging","it","with","the","output","across","all","batches",".","Returns",":","Model","outputs","corresponding","to","the","inputs","fed","."]
code: def run_inference(
      self,
      model_data: RasaModelData,
      batch_size: Union[int, List[int]] = 1,
      output_keys_expected: Optional[List[Text]] = None,
  ) -> Dict[Text, Union[np.ndarray, Dict[Text, Any]]]:
      """Implements bulk inferencing through the model.
  
      Args:
          model_data: Input data to be fed to the model.
          batch_size: Size of batches that the generator should create.
          output_keys_expected: Keys which are expected in the output.
              The output should be filtered to have only these keys before
              merging it with the output across all batches.
  
      Returns:
          Model outputs corresponding to the inputs fed.
      """
      outputs: Dict[Text, Union[np.ndarray, Dict[Text, Any]]] = {}
      (
          data_generator,
          _,
      ) = rasa.utils.train_utils.create_data_generators(
          model_data=model_data,
          batch_sizes=batch_size,
          epochs=1,
          shuffle=False,
      )
      data_iterator = iter(data_generator)
      while True:
          try:
              # data_generator is a tuple of 2 elements - input and output.
              # We only need input, since output is always None and not
              # consumed by our TF graphs.
              batch_in = next(data_iterator)[0]
              batch_out: Dict[
                  Text, Union[np.ndarray, Dict[Text, Any]]
              ] = self._rasa_predict(batch_in)
              if output_keys_expected:
                  batch_out = {
                      key: output
                      for key, output in batch_out.items()
                      if key in output_keys_expected
                  }
              outputs = self._merge_batch_outputs(outputs, batch_out)
          except StopIteration:
              # Generator ran out of batches, time to finish inferencing
              break
      return outputs
  
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 11 for calling the RasaModel obj's underlying member method code with example usage: obj.run_inference(model_data, batch_size, output_keys_expected) and returns: outputs