class_docstr: Class defining categorical distribution type functionality
docstr: Uses the functional implementation of the CrossEntropyLoss class
  https://pytorch.org/docs/master/generated/torch.nn.CrossEntropyLoss.html#torch.nn.CrossEntropyLoss.
  
  Returns the mean row wise cross entropy loss for a single group of categorical columns.
  
  NOTE: the pytorch implementation assumes a numeric target input.
  Therefore, collapse the one hot columns into a numeric target column.
  
  Args:
      X: The original data passed into NOTEARS (i.e. the reconstruction target).
  
      X_hat: The reconstructed data.
  
  Returns:
      Scalar pytorch tensor of the reconstruction loss between X and X_hat.
docstr_tok: ["Uses","the","functional","implementation","of","the","CrossEntropyLoss","class","https",":","\/\/pytorch.org\/docs\/master\/generated\/torch.nn.CrossEntropyLoss.html","#","torch.nn.CrossEntropyLoss",".","Returns","the","mean","row","wise","cross","entropy","loss","for","a","single","group","of","categorical","columns",".","NOTE",":","the","pytorch","implementation","assumes","a","numeric","target","input",".","Therefore",",","collapse","the","one","hot","columns","into","a","numeric","target","column",".","Args",":","X",":","The","original","data","passed","into","NOTEARS","(","i.e",".","the","reconstruction","target",")",".","X_hat",":","The","reconstructed","data",".","Returns",":","Scalar","pytorch","tensor","of","the","reconstruction","loss","between","X","and","X_hat","."]
code: def loss(self, X: torch.Tensor, X_hat: torch.Tensor) -> torch.Tensor:
      """
      Uses the functional implementation of the CrossEntropyLoss class
      https://pytorch.org/docs/master/generated/torch.nn.CrossEntropyLoss.html#torch.nn.CrossEntropyLoss.
  
      Returns the mean row wise cross entropy loss for a single group of categorical columns.
  
      NOTE: the pytorch implementation assumes a numeric target input.
      Therefore, collapse the one hot columns into a numeric target column.
  
      Args:
          X: The original data passed into NOTEARS (i.e. the reconstruction target).
  
          X_hat: The reconstructed data.
  
      Returns:
          Scalar pytorch tensor of the reconstruction loss between X and X_hat.
      """
  
      return nn.functional.cross_entropy(
          input=X_hat[:, self.idx_group],
          target=self._to_index(X[:, self.idx_group]),
          reduction="mean",
      )
  
imports: from copy import deepcopy
  from typing import Dict, List, Tuple
  import numpy
  import torch
  from sklearn.preprocessing import OneHotEncoder
  from torch import nn
  from causalnex.structure.pytorch.dist_type._base import DistTypeBase, ExpandColumnsMixin
  from causalnex.structure.structuremodel import StructureModel
label_desc: Use image node_id 9 for calling the DistTypeCategorical obj's underlying member method code with example usage: obj.loss(X, X_hat) and returns: nn