class_docstr: Represents a non-projective dependency CRF.
  
  For references see:
  
  * Non-projective dependency parsing using spanning tree algorithms :cite:`mcdonald2005non`
  * Structured prediction models via the matrix-tree theorem :cite:`koo2007structured`
  
  Event shape is of the form:
  
  Parameters:
     log_potentials (tensor) : event shape (*N x N*) head, child  with
                               arc scores with root scores on diagonal e.g.
                               :math:`\phi(i, j)` where :math:`\phi(i, i)` is (root, i).
  
  Compact representation: N long tensor in [0, .. N] (indexing is +1)
  
  Note: Does not currently implement argmax (Chiu-Liu) or sampling.
docstr: Compute marginals for distribution :math:`p(z_t)`.
  
  Algorithm is :math:`O(N^3)` but very fast on batched GPU.
  
  Returns:
      marginals (*batch_shape x event_shape*)
docstr_tok: ["Compute","marginals","for","distribution",":","math",":","`","p","(","z_t",")","`",".","Algorithm","is",":","math",":","`","O","(","N^3",")","`","but","very","fast","on","batched","GPU",".","Returns",":","marginals","(","*","batch_shape","x","event_shape","*",")"]
code: def marginals(self):
      """
      Compute marginals for distribution :math:`p(z_t)`.
  
      Algorithm is :math:`O(N^3)` but very fast on batched GPU.
  
      Returns:
          marginals (*batch_shape x event_shape*)
      """
      return deptree_nonproj(
          self.log_potentials, self.multiroot, self.lengths
      )
  
imports: import torch
  from torch.distributions import constraints
  from torch.distributions.distribution import Distribution
  from torch.distributions.utils import lazy_property
  from .linearchain import LinearChain
  from .cky import CKY
  from .semimarkov import SemiMarkov
  from .alignment import Alignment
  from .deptree import DepTree, deptree_nonproj, deptree_part
  from .cky_crf import CKY_CRF
  from .semirings import LogSemiring, MaxSemiring, EntropySemiring, CrossEntropySemiring, KLDivergenceSemiring, MultiSampledSemiring, KMaxSemiring, StdSemiring, GumbelCRFSemiring
label_desc: Use image node_id 2 for calling the NonProjectiveDependencyCRF obj's underlying member method code with example usage: obj.marginals() and returns: deptree_nonproj