class_docstr: Abstract data generator.
class_docstr_tok: ["Abstract","data","generator","."]
code: def _pad_4d_dense_data(feature_array: FeatureArray) -> np.ndarray:
      # in case of dialogue data we may have 4 dimensions
      # batch size x dialogue history length x sequence length x number of features
  
      # as transformers cannot handle 4D tensors pad and reshape the data
      # so that the resulting tensor is 3D
      # the shape is (sum of dialogue history length for all tensors in the
      # batch x max sequence length x number of features)
      # the original shape and the original dialogue length is passed on to the model
      # it can be used to transform the 3D tensor back into 4D
  
      # in order to create 4d tensor inputs, we created "fake" zero features
      # for nonexistent inputs. To save calculation we filter this features before
      # input to tf methods.
      number_of_features = feature_array[0][0].shape[-1]
      array_of_array_of_dense = (
          RasaDataGenerator._filter_out_fake_inputs(feature_array)
      )
      if not array_of_array_of_dense:
          # return empty 3d array with appropriate last dims
          return np.zeros((0, 0, number_of_features), dtype=np.float32)
  
      combined_dialogue_len = sum(
          len(array_of_dense)
          for array_of_dense in array_of_array_of_dense
      )
      max_seq_len = max(
          [
              x.shape[0]
              for array_of_dense in array_of_array_of_dense
              for x in array_of_dense
          ]
      )
  
      data_padded = np.zeros(
          [combined_dialogue_len, max_seq_len, number_of_features],
          dtype=array_of_array_of_dense[0][0].dtype,
      )
  
      current_sum_dialogue_len = 0
      for i, array_of_dense in enumerate(array_of_array_of_dense):
          for j, dense in enumerate(array_of_dense):
              data_padded[
                  current_sum_dialogue_len + j, : dense.shape[0], :
              ] = dense
          current_sum_dialogue_len += len(array_of_dense)
  
      return data_padded.astype(np.float32)
  
imports: import math
  from typing import List, Union, Text, Optional, Any, Tuple, Dict, cast
  import logging
  import scipy.sparse
  import numpy
  from tensorflow.keras.utils import Sequence
  from rasa.utils.tensorflow.constants import SEQUENCE, BALANCED
  from rasa.utils.tensorflow.model_data import RasaModelData, Data, FeatureArray
label_desc: Use image node_id 8 for calling the RasaDataGenerator obj's underlying member method code with example usage: obj._pad_4d_dense_data(feature_array) and returns: data_padded, np