class_docstr: Abstract base class for Hidden Markov Models.
  
  The purpose of this class is to handle duration logic for homogeneous HMMs.
  
  :param int duration: Optional size of the time axis ``event_shape[0]``.
      This is required when sampling from homogeneous HMMs whose parameters
      are not expanded along the time axis.
class_docstr_tok: ["Abstract","base","class","for","Hidden","Markov","Models",".","The","purpose","of","this","class","is","to","handle","duration","logic","for","homogeneous","HMMs",".",":","param","int","duration",":","Optional","size","of","the","time","axis","``","event_shape","[","0","]","``",".","This","is","required","when","sampling","from","homogeneous","HMMs","whose","parameters","are","not","expanded","along","the","time","axis","."]
code: def __init__(
      self, duration, batch_shape, event_shape, validate_args=None
  ):
      if duration is None:
          if event_shape[0] != 1:
              # Infer duration from event_shape.
              duration = event_shape[0]
      elif duration != event_shape[0]:
          if event_shape[0] != 1:
              raise ValueError(
                  "duration, event_shape mismatch: {} vs {}".format(
                      duration, event_shape
                  )
              )
          # Infer event_shape from duration.
          event_shape = torch.Size((duration,) + event_shape[1:])
      self._duration = duration
      super().__init__(batch_shape, event_shape, validate_args)
  
imports: import torch
  import torch.nn.functional
  from pyro.ops.gamma_gaussian import GammaGaussian, gamma_and_mvn_to_gamma_gaussian, gamma_gaussian_tensordot, matrix_and_mvn_to_gamma_gaussian
  from pyro.ops.gaussian import Gaussian, gaussian_tensordot, matrix_and_mvn_to_gaussian, mvn_to_gaussian, sequential_gaussian_filter_sample, sequential_gaussian_tensordot
  from pyro.ops.indexing import Vindex
  from pyro.ops.special import safe_log
  from pyro.ops.tensor_utils import cholesky_solve, safe_cholesky
  from .None import constraints
  from .torch import Categorical, Gamma, Independent, MultivariateNormal
  from .torch_distribution import TorchDistribution
  from .util import broadcast_shape, torch_jit_script_if_tracing
label_desc: Use image node_id 1 to create a new HiddenMarkovModel object from inherited base classes: TorchDistribution with example: obj = HiddenMarkovModel(duration, batch_shape, event_shape, validate_args)