code: def collapse_mixture_of_tastes(tastes_predictions, tastes_attentions):
      """
      Collapses a list of prediction nodes in to a single prediction node.
      :param tastes_predictions:
      :param tastes_attentions:
      :return:
      """
      stacked_predictions = tf.stack(tastes_predictions)
  
      # If there is attention, the attentions are used to weight each prediction
      if tastes_attentions is not None:
          # Stack the attentions and perform softmax across the tastes
          stacked_attentions = tf.stack(tastes_attentions)
          softmax_attentions = tf.nn.softmax(stacked_attentions, axis=0)
  
          # The softmax'd attentions serve as weights for the taste predictions
          weighted_predictions = tf.multiply(
              stacked_predictions, softmax_attentions
          )
          result_prediction = tf.reduce_sum(
              weighted_predictions, axis=0
          )
  
      # If there is no attention, the max prediction is returned
      else:
          result_prediction = tf.reduce_max(stacked_predictions, axis=0)
  
      return result_prediction
  
file_path: tensorrec/tensorrec/recommendation_graphs.py
imports: import tensorflow
label_desc: Use image node_id 7 for calling a global function with example usage: collapse_mixture_of_tastes(tastes_predictions, tastes_attentions) and returns: result_prediction