class_docstr: Sort Pooling Keras layer.
  
  Note that sorting is performed using only the last column of the input tensor as stated in [1], "For convenience,
  we set the last graph convolution to have one channel and only used this single channel for sorting."
  
  [1] An End-to-End Deep Learning Architecture for Graph Classification, M. Zhang, Z. Cui, M. Neumann, and
  Y. Chen, AAAI-18, https://www.aaai.org/ocs/index.php/AAAI/AAAI18/paper/viewPaper/17146
  
  .. seealso:: The :class:`.DeepGraphCNN` model uses this class for graph classification.
  
  Args:
      k (int): The number of rows of output tensor.
      flatten_output (bool): If True then the output tensor is reshaped to vector for each element in the batch.
class_docstr_tok: ["Sort","Pooling","Keras","layer",".","Note","that","sorting","is","performed","using","only","the","last","column","of","the","input","tensor","as","stated","in","[","1","]",",","``","For","convenience",",","we","set","the","last","graph","convolution","to","have","one","channel","and","only","used","this","single","channel","for","sorting",".","''","[","1","]","An","End-to-End","Deep","Learning","Architecture","for","Graph","Classification",",","M.","Zhang",",","Z.","Cui",",","M.","Neumann",",","and","Y.","Chen",",","AAAI-18",",","https",":","\/\/www.aaai.org\/ocs\/index.php\/AAAI\/AAAI18\/paper\/viewPaper\/17146","..","seealso",":",":","The",":","class",":","`",".DeepGraphCNN","`","model","uses","this","class","for","graph","classification",".","Args",":","k","(","int",")",":","The","number","of","rows","of","output","tensor",".","flatten_output","(","bool",")",":","If","True","then","the","output","tensor","is","reshaped","to","vector","for","each","element","in","the","batch","."]
docstr: Applies the layer.
  
  Args:
      embeddings (tensor): the node features (size B x N x Sum F_i)
          where B is the batch size, N is the number of nodes in the largest graph in the batch, and
          F_i is the dimensionality of node features output from the i-th convolutional layer.
      mask (tensor): a boolean mask (size B x N)
  Returns:
      Keras Tensor that represents the output of the layer.
docstr_tok: ["Applies","the","layer",".","Args",":","embeddings","(","tensor",")",":","the","node","features","(","size","B","x","N","x","Sum","F_i",")","where","B","is","the","batch","size",",","N","is","the","number","of","nodes","in","the","largest","graph","in","the","batch",",","and","F_i","is","the","dimensionality","of","node","features","output","from","the","i-th","convolutional","layer",".","mask","(","tensor",")",":","a","boolean","mask","(","size","B","x","N",")","Returns",":","Keras","Tensor","that","represents","the","output","of","the","layer","."]
code: def call(self, embeddings, mask):
      """
      Applies the layer.
  
      Args:
          embeddings (tensor): the node features (size B x N x Sum F_i)
              where B is the batch size, N is the number of nodes in the largest graph in the batch, and
              F_i is the dimensionality of node features output from the i-th convolutional layer.
          mask (tensor): a boolean mask (size B x N)
      Returns:
          Keras Tensor that represents the output of the layer.
      """
  
      outputs = tf.map_fn(
          self._sort_tensor_with_mask,
          (embeddings, mask),
          dtype=embeddings.dtype,
      )
  
      # padding or truncation based on the value of self.k and the graph size (number of nodes)
      outputs_shape = tf.shape(outputs)
  
      outputs = tf.cond(
          tf.math.less(outputs_shape, self.k)[1],
          true_fn=lambda: tf.pad(
              outputs,
              [[0, 0], [0, (self.k - outputs_shape)[1]], [0, 0]],
          ),
          false_fn=lambda: outputs[:, : self.k, :],
      )
  
      if self.flatten_output:
          outputs = tf.reshape(
              outputs,
              [outputs_shape[0], embeddings.shape[-1] * self.k, 1],
          )
  
      return outputs
  
file_path: stellargraph/stellargraph/layer/sort_pooling.py
imports: import tensorflow
  from tensorflow.keras.layers import Layer
  from ..core.experimental import experimental
  from ..core.validation import require_integer_in_range
label_desc: Use image node_id 5 for calling the SortPooling obj's underlying member method code with example usage: obj.call(embeddings, mask) and returns: outputs