class_docstr: Compose embedding by attending to neighbors using simple dot product.
  Concatenates and projects (node, query_rel) to an embedding that is used to
  attend to the neighbor embeddings.
class_docstr_tok: ["Compose","embedding","by","attending","to","neighbors","using","simple","dot","product",".","Concatenates","and","projects","(","node",",","query_rel",")","to","an","embedding","that","is","used","to","attend","to","the","neighbor","embeddings","."]
docstr: Bilinear attention with a diagonal matrix of query.
docstr_tok: ["Bilinear","attention","with","a","diagonal","matrix","of","query","."]
code: def attend(self, node, neighbors, query, nbr_mask, name=""):
      """Bilinear attention with a diagonal matrix of query."""
      node_query = tf.concat([node, query], axis=-1)
      node_emb = tf.matmul(node_query, self.proj_e)
      node_emb = tf.expand_dims(node_emb, 1)
      nbr_scores = tf.squeeze(
          tf.matmul(node_emb, neighbors, transpose_b=True), axis=1
      )
      # mask out non-existing neighbors by adding a large negative number
      nbr_scores += (1 - nbr_mask) * (-1e7)
      attention_probs = tf.squeeze(tf.nn.softmax(nbr_scores, axis=-1))
      self.add_to_collection("attention_probs", attention_probs)
      # add summary to monitor attention weights
      utils.add_histogram_summary(
          attention_probs, self.scope + "/" + name + "/attention_probs"
      )
      attention_emb = tf.reduce_sum(
          tf.expand_dims(attention_probs, -1) * neighbors, 1
      )
      # Now concat attention_emb with node embedding and then project to emb_dim
      concat_emb = tf.concat([node, attention_emb], -1)
      output_emb = tf.matmul(concat_emb, self.proj_w)
      output = tf.cond(
          self.is_train,
          lambda: tf.nn.dropout(
              output_emb, self.dropout, name="dropout"
          ),
          lambda: output_emb,
      )
  
      return output
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  import utils
label_desc: Use image node_id 2 for calling the CosineNbrAttentionEmbedding obj's underlying member method code with example usage: obj.attend(node, neighbors, query, nbr_mask, name) and returns: output