class_docstr: A hidden Markov model with a sparse transition matrix.
  
  A hidden Markov model is an extension of a mixture model to sequences by
  including a transition matrix between the elements of the mixture. Each of
  the algorithms for a hidden Markov model are essentially just a revision
  of those algorithms to incorporate this transition matrix.
  
  This object is a wrapper for a hidden Markov model with a sparse transition
  matrix.
  
  Separately, there are two ways to instantiate the hidden Markov model. The
  first is by passing in a set of distributions, a dense transition matrix, 
  and optionally start/end probabilities. The second is to initialize the
  object without these and then to add edges using the `add_edge` method
  and to add distributions using the `add_distributions` method. Importantly, 
  the way that you choose to initialize the hidden Markov model is independent of the
  implementation that you end up choosing. If you pass in a dense transition
  matrix, this will be converted to a sparse matrix with all the zeros
  dropped if you choose `kind='sparse'`.
  
  
  Parameters
  ----------
  distributions: tuple or list
          A set of distribution objects. These objects do not need to be
          initialized, i.e., can be "Normal()". 
  
  edges: numpy.ndarray, torch.Tensor, or None. shape=(k,k)
          A dense transition matrix of probabilities for how each node or
          distribution passed in connects to each other one. This can contain
          many zeroes, and when paired with `kind='sparse'`, will drop those
          elements from the matrix.
  
  starts: list, numpy.ndarray, torch.Tensor, or None. shape=(k,)
          The probability of starting at each node. If not provided, assumes
          these probabilities are uniform.
  
  ends: list, numpy.ndarray, torch.Tensor, or None. shape=(k,)
          The probability of ending at each node. If not provided, assumes
          these probabilities are uniform.
  
  inertia: float, [0, 1], optional
          Indicates the proportion of the update to apply to the parameters
          during training. When the inertia is 0.0, the update is applied in
          its entirety and the previous parameters are ignored. When the
          inertia is 1.0, the update is entirely ignored and the previous
          parameters are kept, equivalently to if the parameters were frozen.
  
  frozen: bool, optional
          Whether all the parameters associated with this distribution are frozen.
          If you want to freeze individual pameters, or individual values in those
          parameters, you must modify the `frozen` attribute of the tensor or
          parameter directly. Default is False.
  
  check_data: bool, optional
          Whether to check properties of the data and potentially recast it to
          torch.tensors. This does not prevent checking of parameters but can
          slightly speed up computation when you know that your inputs are valid.
          Setting this to False is also necessary for compiling.
class_docstr_tok: ["A","hidden","Markov","model","with","a","sparse","transition","matrix",".","A","hidden","Markov","model","is","an","extension","of","a","mixture","model","to","sequences","by","including","a","transition","matrix","between","the","elements","of","the","mixture",".","Each","of","the","algorithms","for","a","hidden","Markov","model","are","essentially","just","a","revision","of","those","algorithms","to","incorporate","this","transition","matrix",".","This","object","is","a","wrapper","for","a","hidden","Markov","model","with","a","sparse","transition","matrix",".","Separately",",","there","are","two","ways","to","instantiate","the","hidden","Markov","model",".","The","first","is","by","passing","in","a","set","of","distributions",",","a","dense","transition","matrix",",","and","optionally","start\/end","probabilities",".","The","second","is","to","initialize","the","object","without","these","and","then","to","add","edges","using","the","`","add_edge","`","method","and","to","add","distributions","using","the","`","add_distributions","`","method",".","Importantly",",","the","way","that","you","choose","to","initialize","the","hidden","Markov","model","is","independent","of","the","implementation","that","you","end","up","choosing",".","If","you","pass","in","a","dense","transition","matrix",",","this","will","be","converted","to","a","sparse","matrix","with","all","the","zeros","dropped","if","you","choose","`","kind='sparse","'","`",".","Parameters","--","--","--","--","--","distributions",":","tuple","or","list","A","set","of","distribution","objects",".","These","objects","do","not","need","to","be","initialized",",","i.e.",",","can","be","``","Normal","(",")","''",".","edges",":","numpy.ndarray",",","torch.Tensor",",","or","None",".","shape=","(","k",",","k",")","A","dense","transition","matrix","of","probabilities","for","how","each","node","or","distribution","passed","in","connects","to","each","other","one",".","This","can","contain","many","zeroes",",","and","when","paired","with","`","kind='sparse","'","`",",","will","drop","those","elements","from","the","matrix",".","starts",":","list",",","numpy.ndarray",",","torch.Tensor",",","or","None",".","shape=","(","k",",",")","The","probability","of","starting","at","each","node",".","If","not","provided",",","assumes","these","probabilities","are","uniform",".","ends",":","list",",","numpy.ndarray",",","torch.Tensor",",","or","None",".","shape=","(","k",",",")","The","probability","of","ending","at","each","node",".","If","not","provided",",","assumes","these","probabilities","are","uniform",".","inertia",":","float",",","[","0",",","1","]",",","optional","Indicates","the","proportion","of","the","update","to","apply","to","the","parameters","during","training",".","When","the","inertia","is","0.0",",","the","update","is","applied","in","its","entirety","and","the","previous","parameters","are","ignored",".","When","the","inertia","is","1.0",",","the","update","is","entirely","ignored","and","the","previous","parameters","are","kept",",","equivalently","to","if","the","parameters","were","frozen",".","frozen",":","bool",",","optional","Whether","all","the","parameters","associated","with","this","distribution","are","frozen",".","If","you","want","to","freeze","individual","pameters",",","or","individual","values","in","those","parameters",",","you","must","modify","the","`","frozen","`","attribute","of","the","tensor","or","parameter","directly",".","Default","is","False",".","check_data",":","bool",",","optional","Whether","to","check","properties","of","the","data","and","potentially","recast","it","to","torch.tensors",".","This","does","not","prevent","checking","of","parameters","but","can","slightly","speed","up","computation","when","you","know","that","your","inputs","are","valid",".","Setting","this","to","False","is","also","necessary","for","compiling","."]
docstr: Initialize the probability distribution.
  
  This method is meant to only be called internally. It initializes the
  parameters of the distribution and stores its dimensionality. For more
  complex methods, this function will do more.
  
  
  Parameters
  ----------
  X: list, numpy.ndarray, torch.Tensor, shape=(-1, len, self.d), optional
          The data to use to initialize the model. Default is None.
  
  sample_weight: list, tuple, numpy.ndarray, torch.Tensor, optional
          A set of weights for the examples. This can be either of shape
          (-1, len) or a vector of shape (-1,). If None, defaults to ones.
          Default is None.
docstr_tok: ["Initialize","the","probability","distribution",".","This","method","is","meant","to","only","be","called","internally",".","It","initializes","the","parameters","of","the","distribution","and","stores","its","dimensionality",".","For","more","complex","methods",",","this","function","will","do","more",".","Parameters","--","--","--","--","--","X",":","list",",","numpy.ndarray",",","torch.Tensor",",","shape=","(","-1",",","len",",","self.d",")",",","optional","The","data","to","use","to","initialize","the","model",".","Default","is","None",".","sample_weight",":","list",",","tuple",",","numpy.ndarray",",","torch.Tensor",",","optional","A","set","of","weights","for","the","examples",".","This","can","be","either","of","shape","(","-1",",","len",")","or","a","vector","of","shape","(","-1",",",")",".","If","None",",","defaults","to","ones",".","Default","is","None","."]
code: def _initialize(self, X=None, sample_weight=None):
      """Initialize the probability distribution.
  
      This method is meant to only be called internally. It initializes the
      parameters of the distribution and stores its dimensionality. For more
      complex methods, this function will do more.
  
  
      Parameters
      ----------
      X: list, numpy.ndarray, torch.Tensor, shape=(-1, len, self.d), optional
              The data to use to initialize the model. Default is None.
  
      sample_weight: list, tuple, numpy.ndarray, torch.Tensor, optional
              A set of weights for the examples. This can be either of shape
              (-1, len) or a vector of shape (-1,). If None, defaults to ones.
              Default is None.
      """
  
      n = self.n_distributions
      if not hasattr(self, "_edge_log_probs"):
          unpack_edges(self, self.edges, self.starts, self.ends)
          self.n_edges = len(self.edges)
  
      self.distributions = torch.nn.ModuleList(self.distributions)
      super()._initialize(X, sample_weight=sample_weight)
  
imports: import math
  import numpy
  import torch
  from .._utils import _cast_as_tensor
  from .._utils import _cast_as_parameter
  from .._utils import _update_parameter
  from .._utils import _check_parameter
  from ..distributions._distribution import Distribution
  from ._base import _BaseHMM
  from ._base import _check_inputs
label_desc: Use image node_id 2 for calling the SparseHMM obj's underlying member method code with example usage: obj._initialize(X, sample_weight) without return types