class_docstr: The spectral modularity pooling operator from the `"Graph Clustering
  with Graph Neural Networks" <https://arxiv.org/abs/2006.16904>`_ paper.
  
  .. math::
      \mathbf{X}^{\prime} &= {\mathrm{softmax}(\mathbf{S})}^{\top} \cdot
      \mathbf{X}
  
      \mathbf{A}^{\prime} &= {\mathrm{softmax}(\mathbf{S})}^{\top} \cdot
      \mathbf{A} \cdot \mathrm{softmax}(\mathbf{S})
  
  based on dense learned assignments :math:`\mathbf{S} \in \mathbb{R}^{B
  \times N \times C}`.
  Returns the learned cluster assignment matrix, the pooled node feature
  matrix, the coarsened symmetrically normalized adjacency matrix, and three
  auxiliary objectives: (1) The spectral loss
  
  .. math::
      \mathcal{L}_s = - \frac{1}{2m}
      \cdot{\mathrm{Tr}(\mathbf{S}^{\top} \mathbf{B} \mathbf{S})}
  
  where :math:`\mathbf{B}` is the modularity matrix, (2) the orthogonality
  loss
  
  .. math::
      \mathcal{L}_o = {\left\| \frac{\mathbf{S}^{\top} \mathbf{S}}
      {{\|\mathbf{S}^{\top} \mathbf{S}\|}_F} -\frac{\mathbf{I}_C}{\sqrt{C}}
      \right\|}_F
  
  where :math:`C` is the number of clusters, and (3) the cluster loss
  
  .. math::
      \mathcal{L}_c = \frac{\sqrt{C}}{n}
      {\left\|\sum_i\mathbf{C_i}^{\top}\right\|}_F - 1.
  
  .. note::
  
      For an example of using :class:`DMoNPooling`, see
      `examples/proteins_dmon_pool.py
      <https://github.com/pyg-team/pytorch_geometric/blob
      /master/examples/proteins_dmon_pool.py>`_.
  
  Args:
      channels (int or List[int]): Size of each input sample. If given as a
          list, will construct an MLP based on the given feature sizes.
      k (int): The number of clusters.
      dropout (float, optional): Dropout probability. (default: :obj:`0.0`)
class_docstr_tok: ["The","spectral","modularity","pooling","operator","from","the","`","``","Graph","Clustering","with","Graph","Neural","Networks","''","<","https",":","\/\/arxiv.org\/abs\/2006.16904",">","`","_","paper",".","..","math",":",":","\\mathbf","{","X","}","^","{","\\prime","}","&","=","{","\\mathrm","{","softmax","}","(","\\mathbf","{","S","}",")","}","^","{","\\top","}","\\cdot","\\mathbf","{","X","}","\\mathbf","{","A","}","^","{","\\prime","}","&","=","{","\\mathrm","{","softmax","}","(","\\mathbf","{","S","}",")","}","^","{","\\top","}","\\cdot","\\mathbf","{","A","}","\\cdot","\\mathrm","{","softmax","}","(","\\mathbf","{","S","}",")","based","on","dense","learned","assignments",":","math",":","`","\\mathbf","{","S","}","\\in","\\mathbb","{","R","}","^","{","B","\\times","N","\\times","C","}","`",".","Returns","the","learned","cluster","assignment","matrix",",","the","pooled","node","feature","matrix",",","the","coarsened","symmetrically","normalized","adjacency","matrix",",","and","three","auxiliary","objectives",":","(","1",")","The","spectral","loss","..","math",":",":","\\mathcal","{","L","}","_s","=","-","\\frac","{","1","}","{","2m","}","\\cdot","{","\\mathrm","{","Tr","}","(","\\mathbf","{","S","}","^","{","\\top","}","\\mathbf","{","B","}","\\mathbf","{","S","}",")","}","where",":","math",":","`","\\mathbf","{","B","}","`","is","the","modularity","matrix",",","(","2",")","the","orthogonality","loss","..","math",":",":","\\mathcal","{","L","}","_o","=","{","\\left\\|","\\frac","{","\\mathbf","{","S","}","^","{","\\top","}","\\mathbf","{","S","}","}","{","{","\\|\\mathbf","{","S","}","^","{","\\top","}","\\mathbf","{","S","}","\\|","}","_F","}","-\\frac","{","\\mathbf","{","I","}","_C","}","{","\\sqrt","{","C","}","}","\\right\\|","}","_F","where",":","math",":","`","C","`","is","the","number","of","clusters",",","and","(","3",")","the","cluster","loss","..","math",":",":","\\mathcal","{","L","}","_c","=","\\frac","{","\\sqrt","{","C","}","}","{","n","}","{","\\left\\|\\sum_i\\mathbf","{","C_i","}","^","{","\\top","}","\\right\\|","}","_F","-","1",".","..","note",":",":","For","an","example","of","using",":","class",":","`","DMoNPooling","`",",","see","`","examples\/proteins_dmon_pool.py","<","https",":","\/\/github.com\/pyg-team\/pytorch_geometric\/blob","\/master\/examples\/proteins_dmon_pool.py",">","`","_",".","Args",":","channels","(","int","or","List","[","int","]",")",":","Size","of","each","input","sample",".","If","given","as","a","list",",","will","construct","an","MLP","based","on","the","given","feature","sizes",".","k","(","int",")",":","The","number","of","clusters",".","dropout","(","float",",","optional",")",":","Dropout","probability",".","(","default",":",":","obj",":","`","0.0","`",")"]
code: def __init__(
      self,
      channels: Union[int, List[int]],
      k: int,
      dropout: float = 0.0,
  ):
      super().__init__()
  
      if isinstance(channels, int):
          channels = [channels]
  
      from torch_geometric.nn.models.mlp import MLP
  
      self.mlp = MLP(channels + [k], act=None, norm=None)
  
      self.dropout = dropout
  
      self.reset_parameters()
  
file_path: pytorch_geometric/torch_geometric/nn/dense/dmon_pool.py
imports: from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch_geometric.nn.dense.mincut_pool import _rank3_trace
label_desc: Use image node_id 1 to create a new DMoNPooling object from inherited base classes: torch.nn with example: obj = DMoNPooling(channels, k, dropout)