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","."]
code: def _sort_tensor_with_mask(self, inputs):
      embeddings, mask = inputs[0], inputs[1]
  
      masked_sorted_embeddings = tf.gather(
          embeddings,
          tf.argsort(
              tf.boolean_mask(embeddings, mask)[..., -1],
              axis=0,
              direction="DESCENDING",
          ),
      )
  
      embeddings = tf.pad(
          masked_sorted_embeddings,
          [
              [
                  0,
                  (
                      tf.shape(embeddings)[0]
                      - tf.shape(masked_sorted_embeddings)[0]
                  ),
              ],
              [0, 0],
          ],
      )
  
      return embeddings
  
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 4 for calling the SortPooling obj's underlying member method code with example usage: obj._sort_tensor_with_mask(inputs) and returns: embeddings