class_docstr: This prediction function calculates the prediction as the cosine between the user and item representations.
  Prediction = cos(user_repr, item_repr)
class_docstr_tok: ["This","prediction","function","calculates","the","prediction","as","the","cosine","between","the","user","and","item","representations",".","Prediction","=","cos","(","user_repr",",","item_repr",")"]
code: def connect_serial_prediction_graph(
      self,
      tf_user_representation,
      tf_item_representation,
      tf_x_user,
      tf_x_item,
  ):
      normalized_users = tf.nn.l2_normalize(tf_user_representation, 1)
      normalized_items = tf.nn.l2_normalize(tf_item_representation, 1)
      gathered_user_reprs = tf.gather(normalized_users, tf_x_user)
      gathered_item_reprs = tf.gather(normalized_items, tf_x_item)
      return tf.reduce_sum(
          tf.multiply(gathered_user_reprs, gathered_item_reprs), axis=1
      )
  
file_path: tensorrec/tensorrec/prediction_graphs.py
imports: import abc
  import tensorflow
  from .recommendation_graphs import relative_cosine
label_desc: Use image node_id 2 for calling the CosineSimilarityPredictionGraph obj's underlying member method code with example usage: obj.connect_serial_prediction_graph(tf_user_representation, tf_item_representation, tf_x_user, tf_x_item) and returns: tf