class_docstr: Description
  -----------
  The Graph Cross Network.
  
  Parameters
  ----------
  in_dim : int
      The number of input node feature channels.
  out_dim : int
      The number of output node feature channels.
  edge_feat_dim : int, optional
      The number of input edge feature channels. Edge feature
      will be passed to a Linear layer and concatenated to
      input node features. Default: :obj:`0`
  hidden_dim : int, optional
      The number of hidden node feature channels.
      Default: :obj:`96`
  pool_ratios : Union[float, List[float]], optional
      The pooling ratios (for keeping nodes) for each layer.
      For example, if `pool_ratio=0.8`, 80\% nodes will be preserved.
      If a single float number is given, all pooling layers will have the
      same pooling ratio.
      Default: :obj:`[0.9, 0.7]`
  readout_nodes : int, optional
      Number of nodes perserved in the final sort pool operation.
      Default: :obj:`30`
  conv1d_dims : List[int], optional
      The number of kernels of Conv1d operations.
      Default: :obj:`[16, 32]`
  conv1d_kws : List[int], optional
      The kernel size of Conv1d.
      Default: :obj:`[5]`
  cross_weight : float, optional
      The weight parameter used in graph cross layers
      Default: :obj:`1.0`
  fuse_weight : float, optional
      The weight parameter used at the end of GXN for channel fusion.
      Default: :obj:`1.0`
class_docstr_tok: ["Description","--","--","--","--","--","-","The","Graph","Cross","Network",".","Parameters","--","--","--","--","--","in_dim",":","int","The","number","of","input","node","feature","channels",".","out_dim",":","int","The","number","of","output","node","feature","channels",".","edge_feat_dim",":","int",",","optional","The","number","of","input","edge","feature","channels",".","Edge","feature","will","be","passed","to","a","Linear","layer","and","concatenated","to","input","node","features",".","Default",":",":","obj",":","`","0","`","hidden_dim",":","int",",","optional","The","number","of","hidden","node","feature","channels",".","Default",":",":","obj",":","`","96","`","pool_ratios",":","Union","[","float",",","List","[","float","]","]",",","optional","The","pooling","ratios","(","for","keeping","nodes",")","for","each","layer",".","For","example",",","if","`","pool_ratio=0.8","`",",","80\\","%","nodes","will","be","preserved",".","If","a","single","float","number","is","given",",","all","pooling","layers","will","have","the","same","pooling","ratio",".","Default",":",":","obj",":","`","[","0.9",",","0.7","]","`","readout_nodes",":","int",",","optional","Number","of","nodes","perserved","in","the","final","sort","pool","operation",".","Default",":",":","obj",":","`","30","`","conv1d_dims",":","List","[","int","]",",","optional","The","number","of","kernels","of","Conv1d","operations",".","Default",":",":","obj",":","`","[","16",",","32","]","`","conv1d_kws",":","List","[","int","]",",","optional","The","kernel","size","of","Conv1d",".","Default",":",":","obj",":","`","[","5","]","`","cross_weight",":","float",",","optional","The","weight","parameter","used","in","graph","cross","layers","Default",":",":","obj",":","`","1.0","`","fuse_weight",":","float",",","optional","The","weight","parameter","used","at","the","end","of","GXN","for","channel","fusion",".","Default",":",":","obj",":","`","1.0","`"]
code: def __init__(
      self,
      in_dim: int,
      out_dim: int,
      edge_feat_dim: int = 0,
      hidden_dim: int = 96,
      pool_ratios: Union[List[float], float] = [0.9, 0.7],
      readout_nodes: int = 30,
      conv1d_dims: List[int] = [16, 32],
      conv1d_kws: List[int] = [5],
      cross_weight: float = 1.0,
      fuse_weight: float = 1.0,
      dist: int = 1,
  ):
      super(GraphCrossNet, self).__init__()
      self.in_dim = in_dim
      self.out_dim = out_dim
      self.hidden_dim = hidden_dim
      self.edge_feat_dim = edge_feat_dim
      self.readout_nodes = readout_nodes
      conv1d_kws = [hidden_dim] + conv1d_kws
  
      if edge_feat_dim > 0:
          self.in_dim += hidden_dim
          self.e2l_lin = torch.nn.Linear(edge_feat_dim, hidden_dim)
      else:
          self.e2l_lin = None
  
      self.gxn = GraphCrossModule(
          pool_ratios,
          in_dim=self.in_dim,
          out_dim=hidden_dim,
          hidden_dim=hidden_dim // 2,
          cross_weight=cross_weight,
          fuse_weight=fuse_weight,
          dist=dist,
      )
      self.sortpool = SortPooling(readout_nodes)
  
      # final updates
      self.final_conv1 = torch.nn.Conv1d(
          1,
          conv1d_dims[0],
          kernel_size=conv1d_kws[0],
          stride=conv1d_kws[0],
      )
      self.final_maxpool = torch.nn.MaxPool1d(2, 2)
      self.final_conv2 = torch.nn.Conv1d(
          conv1d_dims[0],
          conv1d_dims[1],
          kernel_size=conv1d_kws[1],
          stride=1,
      )
      self.final_dense_dim = int((readout_nodes - 2) / 2 + 1)
      self.final_dense_dim = (
          self.final_dense_dim - conv1d_kws[1] + 1
      ) * conv1d_dims[1]
  
      if self.out_dim > 0:
          self.out_lin = torch.nn.Linear(self.final_dense_dim, out_dim)
  
      self.init_weights()
  
file_path: dgl/examples/pytorch/gxn/networks.py
imports: from typing import List, Tuple, Union
  from layers import *
  import dgl.function
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl.nn.pytorch.glob import SortPooling
label_desc: Use image node_id 1 to create a new GraphCrossNet object from inherited base classes: torch.nn with example: obj = GraphCrossNet(in_dim, out_dim, edge_feat_dim, hidden_dim, pool_ratios, readout_nodes, conv1d_dims, conv1d_kws, cross_weight, fuse_weight, dist)