code: def sample_tree_mcmc(edge_logits, edges, backend="python"):
      """
      Sample a random spanning tree of a dense weighted graph using MCMC.
  
      This uses Gibbs sampling on edges. Consider E undirected edges that can
      move around a graph of ``V=1+E`` vertices. The edges are constrained so
      that no two edges can span the same pair of vertices and so that the edges
      must form a spanning tree. To Gibbs sample, chose one of the E edges at
      random and move it anywhere else in the graph. After we remove the edge,
      notice that the graph is split into two connected components. The
      constraints imply that the edge must be replaced so as to connect the two
      components.  Hence to Gibbs sample, we collect all such bridging
      (vertex,vertex) pairs and sample from them in proportion to
      ``exp(edge_logits)``.
  
      :param torch.Tensor edge_logits: A length-K array of nonnormalized log
          probabilities.
      :param torch.Tensor edges: An E x 2 tensor of initial edges in the form
          of (vertex,vertex) pairs. Each edge should be sorted and the entire
          tensor should be lexicographically sorted.
      :returns: An E x 2 tensor of edges in the form of (vertex,vertex) pairs.
          Each edge should be sorted and the entire tensor should be
          lexicographically sorted.
      :rtype: torch.Tensor
      """
      if backend == "python":
          return _sample_tree_mcmc(edge_logits, edges)
      elif backend == "cpp":
          return _get_cpp_module().sample_tree_mcmc(edge_logits, edges)
      else:
          raise ValueError("unknown backend: {}".format(repr(backend)))
  
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 8 for calling a global function with example usage: sample_tree_mcmc(edge_logits, edges, backend) and returns: _sample_tree_mcmc, _get_cpp_module