code: def random_walk_norm(
      edge_index: Adj,
      edge_weight: Optional[Tensor] = None,
      num_nodes: Optional[int] = None,
  ):
      num_nodes = maybe_num_nodes(edge_index, num_nodes)
  
      if isinstance(edge_index, SparseTensor):
          adj_t = edge_index
          if adj_t.storage.value() is None:
              adj_t = adj_t.set_value(
                  torch.ones(adj_t.nnz()).to(adj_t.device()),
                  layout="coo",
              )
          deg = adj_t.sum(dim=1)
          deg_inv = 1.0 / deg
          deg_inv.masked_fill_(deg_inv == float("inf"), 0)
          adj_t = adj_t.set_value(
              adj_t.storage.value() * deg_inv[adj_t.storage.row()],
              layout="coo",
          )
  
          return adj_t
  
      elif isinstance(edge_index, Tensor):
          row = edge_index[0]
          if edge_weight is None:
              edge_weight = torch.ones(
                  edge_index.size(1), device=edge_index.device
              )
          deg = scatter_add(
              edge_weight, index=row, dim=0, dim_size=num_nodes
          )
          deg_inv = 1.0 / deg
          deg_inv.masked_fill_(deg_inv == float("inf"), 0)
          edge_weight = deg_inv[row] * edge_weight
          return edge_index, edge_weight
  
imports: import time
  import hydra
  from omegaconf import OmegaConf
  import torch
  from torch_geometric.nn.conv.gcn_conv import gcn_norm
  from dig.lsgraph.dataset import get_data, SubgraphLoader, EvalSubgraphLoader
  from dig.lsgraph.method.GraphFMOB.metis import metis, permute
  import dig.lsgraph.method.GraphFMOB.models
  from dig.lsgraph.method.GraphFMOB.utils import compute_micro_f1, dropout
  from torch import Tensor
  from typing import Optional
  from torch_geometric.typing import Adj
  from torch_geometric.utils.num_nodes import maybe_num_nodes
  from torch_scatter import scatter_add
  from torch_sparse import SparseTensor
  import logging
label_desc: Use image node_id 1 for calling a global function with example usage: random_walk_norm(edge_index, edge_weight, num_nodes) and returns: adj_t, edge_index,  edge_weight