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 _validate_sample(self, value):
      if value.dim() < self.event_dim:
          raise ValueError(
              "value has too few dimensions: {}".format(value.shape)
          )
  
      if self.duration is not None:
          super()._validate_sample(value)
          return
  
      # Temporarily infer duration from value.shape.
      duration = value.size(-self.event_dim)
      old = self._event_shape
      new = torch.Size((duration,)) + self._event_shape[1:]
      try:
          self._event_shape = new
          super()._validate_sample(value)
      finally:
          self._event_shape = old
  
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 3 for calling the HiddenMarkovModel obj's underlying member method code with example usage: obj._validate_sample(value) without return types