class_docstr: A joint categorical distribution.
  
  A joint categorical distribution models the probability of a vector of
  categorical values occuring without assuming that the dimensions are
  independent from each other. Essentially, it is a Categorical distribution
  without the assumption that the dimensions are independent of each other. 
  
  There are two ways to initialize this object. The first is to pass in
  the tensor of probablity parameters, at which point they can immediately be
  used. The second is to not pass in the rate parameters and then call
  either `fit` or `summary` + `from_summaries`, at which point the 
  probability parameters will be learned from data.
  
  
  Parameters
  ----------
  probs: list, numpy.ndarray, torch.tensor, or None, shape=*n_categories
          A tensor where each dimension corresponds to one column in the data
          set being modeled and the size of each dimension is the number of
          categories in that column, e.g., if the data being modeled is binary 
          and has shape (5, 4), this will be a tensor with shape (2, 2, 2, 2).
          Default is None.
  
  n_categories: list, numpy.ndarray, torch.tensor, or None, shape=(d,)
          A vector with the maximum number of categories that each column
          can have. If not given, this will be inferred from the data. Default
          is None.
  
  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.
  
  pseudocount: float, optional
          A number of observations to add to each entry in the probability
          distribution during training. A higher value will smooth the 
          distributions more. Default is 0.
  
  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","joint","categorical","distribution",".","A","joint","categorical","distribution","models","the","probability","of","a","vector","of","categorical","values","occuring","without","assuming","that","the","dimensions","are","independent","from","each","other",".","Essentially",",","it","is","a","Categorical","distribution","without","the","assumption","that","the","dimensions","are","independent","of","each","other",".","There","are","two","ways","to","initialize","this","object",".","The","first","is","to","pass","in","the","tensor","of","probablity","parameters",",","at","which","point","they","can","immediately","be","used",".","The","second","is","to","not","pass","in","the","rate","parameters","and","then","call","either","`","fit","`","or","`","summary","`","+","`","from_summaries","`",",","at","which","point","the","probability","parameters","will","be","learned","from","data",".","Parameters","--","--","--","--","--","probs",":","list",",","numpy.ndarray",",","torch.tensor",",","or","None",",","shape=","*","n_categories","A","tensor","where","each","dimension","corresponds","to","one","column","in","the","data","set","being","modeled","and","the","size","of","each","dimension","is","the","number","of","categories","in","that","column",",","e.g.",",","if","the","data","being","modeled","is","binary","and","has","shape","(","5",",","4",")",",","this","will","be","a","tensor","with","shape","(","2",",","2",",","2",",","2",")",".","Default","is","None",".","n_categories",":","list",",","numpy.ndarray",",","torch.tensor",",","or","None",",","shape=","(","d",",",")","A","vector","with","the","maximum","number","of","categories","that","each","column","can","have",".","If","not","given",",","this","will","be","inferred","from","the","data",".","Default","is","None",".","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",".","pseudocount",":","float",",","optional","A","number","of","observations","to","add","to","each","entry","in","the","probability","distribution","during","training",".","A","higher","value","will","smooth","the","distributions","more",".","Default","is","0.","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: 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. For a joint categorical distribution, each value must be an
  integer category that is smaller than the maximum number of categories
  for each feature.
  
  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",".","For","a","joint","categorical","distribution",",","each","value","must","be","an","integer","category","that","is","smaller","than","the","maximum","number","of","categories","for","each","feature",".","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. For a joint categorical distribution, each value must be an
      integer category that is smaller than the maximum number of categories
      for each feature.
  
      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",
          value_set=tuple(range(max(self.n_categories) + 1)),
          ndim=2,
          shape=(-1, self.d),
          check_parameter=self.check_data,
      )
  
      logps = torch.zeros(len(X), dtype=self.probs.dtype)
      for i in range(len(X)):
          logps[i] = self._log_probs[tuple(X[i])]
  
      return logps
  
file_path: pomegranate/pomegranate/distributions/joint_categorical.py
imports: 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 .._utils import _reshape_weights
  from ._distribution import Distribution
  from .categorical import Categorical
label_desc: Use image node_id 5 for calling the JointCategorical obj's underlying member method code with example usage: obj.log_probability(X) and returns: logps