class_docstr: Represents hidden-markov smoothing with C hidden states.
  
  Event shape is of the form:
  
  Parameters:
      transition (tensor): log-probabilities (*C X C*) :math:`p(z_n| z_n-1)`
      emission (tensor): log-probabilities (*V x C*)  :math:`p(x_n| z_n)`
      init (tensor): log-probabilities (*C*) :math:`p(z_1)`
      observations (long tensor): indices (*batch x N*) between [0, V-1]
  
  Compact representation: N long tensor in [0, ..., C-1]
  
  Implemented as a special case of linear chain CRF.
code: def __init__(
      self,
      transition,
      emission,
      init,
      observations,
      lengths=None,
      validate_args=False,
  ):
      log_potentials = HMM.struct.hmm(
          transition, emission, init, observations
      )
      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 HMM object from inherited base classes: StructDistribution with example: obj = HMM(transition, emission, init, observations, lengths, validate_args)