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","``","."]
code: def __init__(
      self,
      sim_metric_type="weighted_cosine",
      num_heads=1,
      top_k_neigh=None,
      epsilon_neigh=None,
      smoothness_ratio=None,
      connectivity_ratio=None,
      sparsity_ratio=None,
      input_size=None,
      hidden_size=None,
  ):
      super(DynamicGraphConstructionBase, self).__init__()
      assert (
          top_k_neigh is None or epsilon_neigh is None
      ), "top_k_neigh and epsilon_neigh cannot be activated at the same time!"
      self.top_k_neigh = top_k_neigh
      self.epsilon_neigh = epsilon_neigh
      self.sim_metric_type = sim_metric_type
      self.smoothness_ratio = smoothness_ratio
      self.connectivity_ratio = connectivity_ratio
      self.sparsity_ratio = sparsity_ratio
  
      if self.sim_metric_type == "attention":
          self.mask_off_val = -INF
          self.linear_sims = nn.ModuleList(
              [
                  nn.Linear(input_size, hidden_size, bias=False)
                  for _ in range(num_heads)
              ]
          )
      elif self.sim_metric_type == "weighted_cosine":
          self.mask_off_val = 0
          self.weight = torch.Tensor(num_heads, input_size)
          self.weight = nn.Parameter(
              nn.init.xavier_uniform_(self.weight)
          )
      elif self.sim_metric_type == "gat_attention":
          self.mask_off_val = -INF
          self.linear_sims1 = nn.ModuleList(
              [
                  nn.Linear(input_size, 1, bias=False)
                  for _ in range(num_heads)
              ]
          )
          self.linear_sims2 = nn.ModuleList(
              [
                  nn.Linear(input_size, 1, bias=False)
                  for _ in range(num_heads)
              ]
          )
          self.leakyrelu = nn.LeakyReLU(0.2)
      elif self.sim_metric_type == "rbf_kernel":
          self.mask_off_val = 0
          self.precision_inv_dis = nn.Parameter(torch.Tensor(1, 1))
          self.precision_inv_dis.data.uniform_(0, 1.0)
          self.weight = nn.Parameter(
              nn.init.xavier_uniform_(
                  torch.Tensor(input_size, hidden_size)
              )
          )
      elif self.sim_metric_type == "cosine":
          self.mask_off_val = 0
      else:
          raise RuntimeError(
              "Unknown sim_metric_type: {}".format(self.sim_metric_type)
          )
  
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 1 to create a new DynamicGraphConstructionBase object from inherited base classes: nn with example: obj = DynamicGraphConstructionBase(sim_metric_type, num_heads, top_k_neigh, epsilon_neigh, smoothness_ratio, connectivity_ratio, sparsity_ratio, input_size, hidden_size)