class_docstr: Distribution over spanning trees on a fixed number ``V`` of vertices.
  
  A tree is represented as :class:`torch.LongTensor` ``edges`` of shape
  ``(V-1,2)`` satisfying the following properties:
  
  1. The edges constitute a tree, i.e. are connected and cycle free.
  2. Each edge ``(v1,v2) = edges[e]`` is sorted, i.e. ``v1 < v2``.
  3. The entire tensor is sorted in colexicographic order.
  
  Use :func:`validate_edges` to verify `edges` are correctly formed.
  
  The ``edge_logits`` tensor has one entry for each of the ``V*(V-1)//2``
  edges in the complete graph on ``V`` vertices, where edges are each sorted
  and the edge order is colexicographic::
  
      (0,1), (0,2), (1,2), (0,3), (1,3), (2,3), (0,4), (1,4), (2,4), ...
  
  This ordering corresponds to the size-independent pairing function::
  
      k = v1 + v2 * (v2 - 1) // 2
  
  where ``k`` is the rank of the edge ``(v1,v2)`` in the complete graph.
  To convert a matrix of edge logits to the linear representation used here::
  
      assert my_matrix.shape == (V, V)
      i, j = make_complete_graph(V)
      edge_logits = my_matrix[i, j]
  
  :param torch.Tensor edge_logits: A tensor of length ``V*(V-1)//2``
      containing logits (aka negative energies) of all edges in the complete
      graph on ``V`` vertices. See above comment for edge ordering.
  :param dict sampler_options: An optional dict of sampler options including:
      ``mcmc_steps`` defaulting to a single MCMC step (which is pretty good);
      ``initial_edges`` defaulting to a cheap approximate sample;
      ``backend`` one of "python" or "cpp", defaulting to "python".
docstr: This sampler is implemented using MCMC run for a small number of steps
  after being initialized by a cheap approximate sampler. This sampler is
  approximate and cubic time. This is faster than the classic
  Aldous-Broder sampler [1,2], especially for graphs with large mixing
  time. Recent research [3,4] proposes samplers that run in
  sub-matrix-multiply time but are more complex to implement.
  
  **References**
  
  [1] `Generating random spanning trees`
      Andrei Broder (1989)
  [2] `The Random Walk Construction of Uniform Spanning Trees and Uniform Labelled Trees`,
      David J. Aldous (1990)
  [3] `Sampling Random Spanning Trees Faster than Matrix Multiplication`,
      David Durfee, Rasmus Kyng, John Peebles, Anup B. Rao, Sushant Sachdeva
      (2017) https://arxiv.org/abs/1611.07451
  [4] `An almost-linear time algorithm for uniform random spanning tree generation`,
      Aaron Schild (2017) https://arxiv.org/abs/1711.06455
docstr_tok: ["This","sampler","is","implemented","using","MCMC","run","for","a","small","number","of","steps","after","being","initialized","by","a","cheap","approximate","sampler",".","This","sampler","is","approximate","and","cubic","time",".","This","is","faster","than","the","classic","Aldous-Broder","sampler","[","1,2","]",",","especially","for","graphs","with","large","mixing","time",".","Recent","research","[","3,4","]","proposes","samplers","that","run","in","sub-matrix-multiply","time","but","are","more","complex","to","implement",".","*","*","References","*","*","[","1","]","`","Generating","random","spanning","trees","`","Andrei","Broder","(","1989",")","[","2","]","`","The","Random","Walk","Construction","of","Uniform","Spanning","Trees","and","Uniform","Labelled","Trees","`",",","David","J.","Aldous","(","1990",")","[","3","]","`","Sampling","Random","Spanning","Trees","Faster","than","Matrix","Multiplication","`",",","David","Durfee",",","Rasmus","Kyng",",","John","Peebles",",","Anup","B.","Rao",",","Sushant","Sachdeva","(","2017",")","https",":","\/\/arxiv.org\/abs\/1611.07451","[","4","]","`","An","almost-linear","time","algorithm","for","uniform","random","spanning","tree","generation","`",",","Aaron","Schild","(","2017",")","https",":","\/\/arxiv.org\/abs\/1711.06455"]
code: def sample(self, sample_shape=torch.Size()):
      """
      This sampler is implemented using MCMC run for a small number of steps
      after being initialized by a cheap approximate sampler. This sampler is
      approximate and cubic time. This is faster than the classic
      Aldous-Broder sampler [1,2], especially for graphs with large mixing
      time. Recent research [3,4] proposes samplers that run in
      sub-matrix-multiply time but are more complex to implement.
  
      **References**
  
      [1] `Generating random spanning trees`
          Andrei Broder (1989)
      [2] `The Random Walk Construction of Uniform Spanning Trees and Uniform Labelled Trees`,
          David J. Aldous (1990)
      [3] `Sampling Random Spanning Trees Faster than Matrix Multiplication`,
          David Durfee, Rasmus Kyng, John Peebles, Anup B. Rao, Sushant Sachdeva
          (2017) https://arxiv.org/abs/1611.07451
      [4] `An almost-linear time algorithm for uniform random spanning tree generation`,
          Aaron Schild (2017) https://arxiv.org/abs/1711.06455
      """
      if sample_shape:
          raise NotImplementedError(
              "SpanningTree does not support batching"
          )
      edges = sample_tree(self.edge_logits, **self.sampler_options)
      assert edges.dim() >= 2 and edges.shape[-2:] == self.event_shape
      return edges
  
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 the SpanningTree obj's underlying member method code with example usage: obj.sample(sample_shape) and returns: edges