class_docstr_tok: []
code: def compute_degree(self, edge_index, num_nodes):
      row, col = edge_index
      deg = degree(row, num_nodes)
      deg = deg.view((-1, 1))
  
      if self.onehot_maxdeg is not None and self.onehot_maxdeg > 0:
          max_deg = torch.tensor(self.onehot_maxdeg, dtype=deg.dtype)
          deg_capped = torch.min(deg, max_deg).type(torch.int64)
          deg_onehot = nn.functional.one_hot(
              deg_capped.view(-1), num_classes=self.onehot_maxdeg + 1
          )
          deg_onehot = deg_onehot.type(deg.dtype)
      else:
          deg_onehot = self.empty_feature(num_nodes)
  
      if not self.degree:
          deg = self.empty_feature(num_nodes)
  
      return deg, deg_onehot
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.utils import degree, remove_self_loops, add_self_loops
label_desc: Use image node_id 3 for calling the FeatureExpander obj's underlying member method code with example usage: obj.compute_degree(edge_index, num_nodes) and returns: deg,  deg_onehot