code: def _add_edge(grid, edge_ids, neighbors, components, e, k):
      """
      Add an edge connecting two components to create a spanning tree.
      """
      edge_ids[e] = k
      v1 = grid[0, k].item()
      v2 = grid[1, k].item()
      neighbors[v1].add(v2)
      neighbors[v2].add(v1)
      components.fill_(0)
  
imports: import itertools
  import math
  import torch
  from torch.distributions import constraints
  from torch.distributions.utils import lazy_property
  from pyro.distributions.torch_distribution import TorchDistribution
label_desc: Use image node_id 5 for calling a global function with example usage: _add_edge(grid, edge_ids, neighbors, components, e, k) without return types