class_docstr: An independent components distribution object.
  
  A distribution made up of independent, univariate, distributions that each
  model a single feature in the data. This means that instead of using a
  single type of distribution to model all of the features in your data, you
  use one distribution per feature. Note that this will likely be slower
  than using a single distribution because the amount of batching possible
  will go down significantly.
  
  There are two ways to initialize this object. The first is to pass in a
  set of distributions that are all initialized with parameters, at which
  point this distribution can be immediately used for inference. The second
  is to pass in a set of distributions that are not initialized with
  parameters, and then call either `fit` or `summary` + `from_summaries` to
  learn the parameters of all the distributions.
  
  
  Parameters
  ----------
  distributions: list, tuple, numpy.ndarray, torch.Tensor, shape=(d,)
          An ordered iterable containing all of the distributions, one per
          feature, that will be used.
  
  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: ["An","independent","components","distribution","object",".","A","distribution","made","up","of","independent",",","univariate",",","distributions","that","each","model","a","single","feature","in","the","data",".","This","means","that","instead","of","using","a","single","type","of","distribution","to","model","all","of","the","features","in","your","data",",","you","use","one","distribution","per","feature",".","Note","that","this","will","likely","be","slower","than","using","a","single","distribution","because","the","amount","of","batching","possible","will","go","down","significantly",".","There","are","two","ways","to","initialize","this","object",".","The","first","is","to","pass","in","a","set","of","distributions","that","are","all","initialized","with","parameters",",","at","which","point","this","distribution","can","be","immediately","used","for","inference",".","The","second","is","to","pass","in","a","set","of","distributions","that","are","not","initialized","with","parameters",",","and","then","call","either","`","fit","`","or","`","summary","`","+","`","from_summaries","`","to","learn","the","parameters","of","all","the","distributions",".","Parameters","--","--","--","--","--","distributions",":","list",",","tuple",",","numpy.ndarray",",","torch.Tensor",",","shape=","(","d",",",")","An","ordered","iterable","containing","all","of","the","distributions",",","one","per","feature",",","that","will","be","used",".","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: Calculate the log probability of each example.
  
  This method calculates the log probability of each example given the
  parameters of the distribution. The examples must be given in a 2D
  format.
  
  Note: This differs from some other log probability calculation
  functions, like those in torch.distributions, because it is not
  returning the log probability of each feature independently, but rather
  the total log probability of the entire example.
  
  
  Parameters
  ----------
  X: list, tuple, numpy.ndarray, torch.Tensor, shape=(-1, self.d)
          A set of examples to evaluate.
  
  
  Returns
  -------
  logp: torch.Tensor, shape=(-1,)
          The log probability of each example.
docstr_tok: ["Calculate","the","log","probability","of","each","example",".","This","method","calculates","the","log","probability","of","each","example","given","the","parameters","of","the","distribution",".","The","examples","must","be","given","in","a","2D","format",".","Note",":","This","differs","from","some","other","log","probability","calculation","functions",",","like","those","in","torch.distributions",",","because","it","is","not","returning","the","log","probability","of","each","feature","independently",",","but","rather","the","total","log","probability","of","the","entire","example",".","Parameters","--","--","--","--","--","X",":","list",",","tuple",",","numpy.ndarray",",","torch.Tensor",",","shape=","(","-1",",","self.d",")","A","set","of","examples","to","evaluate",".","Returns","--","--","--","-","logp",":","torch.Tensor",",","shape=","(","-1",",",")","The","log","probability","of","each","example","."]
code: def log_probability(self, X):
      """Calculate the log probability of each example.
  
      This method calculates the log probability of each example given the
      parameters of the distribution. The examples must be given in a 2D
      format.
  
      Note: This differs from some other log probability calculation
      functions, like those in torch.distributions, because it is not
      returning the log probability of each feature independently, but rather
      the total log probability of the entire example.
  
  
      Parameters
      ----------
      X: list, tuple, numpy.ndarray, torch.Tensor, shape=(-1, self.d)
              A set of examples to evaluate.
  
  
      Returns
      -------
      logp: torch.Tensor, shape=(-1,)
              The log probability of each example.
      """
  
      X = _check_parameter(
          _cast_as_tensor(X), "X", ndim=2, shape=(-1, self.d)
      )
  
      logp = torch.zeros(X.shape[0])
      for i, d in enumerate(self.distributions):
          if isinstance(X, torch.masked.MaskedTensor):
              logp.add_(d.log_probability(X[:, i : i + 1])._masked_data)
          else:
              logp.add_(d.log_probability(X[:, i : i + 1]))
  
      return logp
  
file_path: pomegranate/pomegranate/distributions/independent_components.py
imports: 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 .._utils import _reshape_weights
  from ._distribution import Distribution
label_desc: Use image node_id 5 for calling the IndependentComponents obj's underlying member method code with example usage: obj.log_probability(X) and returns: logp