class_docstr: Base implementation of unsupervised GraphSAGE
class_docstr_tok: ["Base","implementation","of","unsupervised","GraphSAGE"]
code: def _accuracy(self):
      # shape: [batch_size]
      aff = self.link_pred_layer.affinity(self.outputs1, self.outputs2)
      # shape : [batch_size x num_neg_samples]
      self.neg_aff = self.link_pred_layer.neg_cost(
          self.outputs1, self.neg_outputs
      )
      self.neg_aff = tf.reshape(
          self.neg_aff, [self.batch_size, FLAGS.neg_sample_size]
      )
      _aff = tf.expand_dims(aff, axis=1)
      self.aff_all = tf.concat(axis=1, values=[self.neg_aff, _aff])
      size = tf.shape(self.aff_all)[1]
      _, indices_of_ranks = tf.nn.top_k(self.aff_all, k=size)
      _, self.ranks = tf.nn.top_k(-indices_of_ranks, k=size)
      self.mrr = tf.reduce_mean(
          tf.div(1.0, tf.cast(self.ranks[:, -1] + 1, tf.float32))
      )
      tf.summary.scalar("mrr", self.mrr)
  
imports: from collections import namedtuple
  import tensorflow
  import math
  import graphsage.layers
  import graphsage.metrics
  from .prediction import BipartiteEdgePredLayer
  from .aggregators import MeanAggregator, MaxPoolingAggregator, MeanPoolingAggregator, SeqAggregator, GCNAggregator
label_desc: Use image node_id 7 for calling the SampleAndAggregate obj's underlying member method code with example usage: obj._accuracy() without return types