class_docstr: Base class for dynamic graph construction.
  
  Parameters
  ----------
  sim_metric_type : str, optional
      Specify similarity metric function type including "attention",
      "weighted_cosine", "gat_attention", "rbf_kernel", and "cosine".
      Default: ``"weighted_cosine"``.
  num_heads : int, optional
      Specify the number of heads for multi-head similarity metric
      function, default: ``1``.
  top_k_neigh : int, optional
      Specify the top k value for knn neighborhood graph sparsificaiton,
      default: ``None``.
  epsilon_neigh : float, optional
      Specify the epsilon value (i.e., between ``0`` and ``1``) for
      epsilon neighborhood graph sparsificaiton, default: ``None``.
  smoothness_ratio : float, optional
      Specify the smoothness ratio (i.e., between ``0`` and ``1``)
      for graph regularization on smoothness, default: ``None``.
  connectivity_ratio : float, optional
      Specify the connectivity ratio (i.e., between ``0`` and ``1``)
      for graph regularization on connectivity, default: ``None``.
  sparsity_ratio : float, optional
      Specify the sparsity ratio (i.e., between ``0`` and ``1``)
      for graph regularization on sparsity, default: ``None``.
  input_size : int, optional
      The dimension of input embeddings, default: ``None``.
  hidden_size : int, optional
      The dimension of hidden layers, default: ``None``.
class_docstr_tok: ["Base","class","for","dynamic","graph","construction",".","Parameters","--","--","--","--","--","sim_metric_type",":","str",",","optional","Specify","similarity","metric","function","type","including","``","attention","''",",","``","weighted_cosine","''",",","``","gat_attention","''",",","``","rbf_kernel","''",",","and","``","cosine","''",".","Default",":","``","``","weighted_cosine","''","``",".","num_heads",":","int",",","optional","Specify","the","number","of","heads","for","multi-head","similarity","metric","function",",","default",":","``","1","``",".","top_k_neigh",":","int",",","optional","Specify","the","top","k","value","for","knn","neighborhood","graph","sparsificaiton",",","default",":","``","None","``",".","epsilon_neigh",":","float",",","optional","Specify","the","epsilon","value","(","i.e.",",","between","``","0","``","and","``","1","``",")","for","epsilon","neighborhood","graph","sparsificaiton",",","default",":","``","None","``",".","smoothness_ratio",":","float",",","optional","Specify","the","smoothness","ratio","(","i.e.",",","between","``","0","``","and","``","1","``",")","for","graph","regularization","on","smoothness",",","default",":","``","None","``",".","connectivity_ratio",":","float",",","optional","Specify","the","connectivity","ratio","(","i.e.",",","between","``","0","``","and","``","1","``",")","for","graph","regularization","on","connectivity",",","default",":","``","None","``",".","sparsity_ratio",":","float",",","optional","Specify","the","sparsity","ratio","(","i.e.",",","between","``","0","``","and","``","1","``",")","for","graph","regularization","on","sparsity",",","default",":","``","None","``",".","input_size",":","int",",","optional","The","dimension","of","input","embeddings",",","default",":","``","None","``",".","hidden_size",":","int",",","optional","The","dimension","of","hidden","layers",",","default",":","``","None","``","."]
docstr: Graph graph regularization loss.
  
  Parameters
  ----------
  adj : torch.Tensor
      The adjacency matrix.
  node_feat : torch.Tensor
      The node feature matrix.
  
  Returns
  -------
  torch.float32
      The graph regularization loss.
docstr_tok: ["Graph","graph","regularization","loss",".","Parameters","--","--","--","--","--","adj",":","torch.Tensor","The","adjacency","matrix",".","node_feat",":","torch.Tensor","The","node","feature","matrix",".","Returns","--","--","--","-","torch.float32","The","graph","regularization","loss","."]
code: def compute_graph_regularization(self, adj, node_feat):
      """Graph graph regularization loss.
  
      Parameters
      ----------
      adj : torch.Tensor
          The adjacency matrix.
      node_feat : torch.Tensor
          The node feature matrix.
  
      Returns
      -------
      torch.float32
          The graph regularization loss.
      """
      graph_reg = 0
      if self.smoothness_ratio not in (0, None):
          for i in range(adj.shape[0]):
              L = torch.diagflat(torch.sum(adj[i], -1)) - adj[i]
              graph_reg += (
                  self.smoothness_ratio
                  * torch.trace(
                      torch.mm(
                          node_feat[i].transpose(-1, -2),
                          torch.mm(L, node_feat[i]),
                      )
                  )
                  / int(np.prod(adj.shape))
              )
  
      if self.connectivity_ratio not in (0, None):
          ones_vec = torch.ones(adj.shape[:-1]).to(adj.device)
          graph_reg += (
              -self.connectivity_ratio
              * torch.matmul(
                  ones_vec.unsqueeze(1),
                  torch.log(
                      torch.matmul(adj, ones_vec.unsqueeze(-1))
                      + VERY_SMALL_NUMBER
                  ),
              ).sum()
              / adj.shape[0]
              / adj.shape[-1]
          )
  
      if self.sparsity_ratio not in (0, None):
          graph_reg += (
              self.sparsity_ratio
              * torch.sum(torch.pow(adj, 2))
              / int(np.prod(adj.shape))
          )
  
      return graph_reg
  
imports: import numpy
  import torch
  import torch.nn.functional
  from scipy import sparse
  from torch import nn
  from ..utils.constants import INF, VERY_SMALL_NUMBER
  from ..utils.generic_utils import normalize_adj, sparse_mx_to_torch_sparse_tensor
label_desc: Use image node_id 5 for calling the DynamicGraphConstructionBase obj's underlying member method code with example usage: obj.compute_graph_regularization(adj, node_feat) and returns: graph_reg