class_docstr: Represents basic alignment algorithm, i.e. dynamic-time warping, Needleman-Wunsch, and Smith-Waterman.
  
  Event shape is of the form:
  
  Parameters:
      log_potentials (tensor) : event_shape (*N x M x 3*), e.g.
                                  :math:`\phi(i, j, op)`
                                Ops are 0 -> j-1, 1->i-1,j-1, and 2->i-1
      local (bool): if true computes local alignment (Smith-Waterman), else Needleman-Wunsch
      max_gap (int or None): the maximum gap to allow in the dynamic program
      lengths (long tensor) : batch shape integers for length masking.
  
  
  Implementation uses convolution and linear-scan. Use max_gap for long sequences.
  
  * Parallel Time: :math:`O(\log (M + N))` parallel merges.
  * Forward Memory: :math:`O((M+N)^2)`
code: def __init__(
      self,
      log_potentials,
      local=False,
      lengths=None,
      max_gap=None,
      validate_args=False,
  ):
      self.local = local
      self.max_gap = max_gap
      super().__init__(
          log_potentials, lengths, validate_args=validate_args
      )
  
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 1 to create a new AlignmentCRF object from inherited base classes: StructDistribution with example: obj = AlignmentCRF(log_potentials, local, lengths, max_gap, validate_args)