class_docstr: Class defining ordinal distribution type functionality
docstr: Uses the cumulative link function to model the ordered categorical variables.
  See "Statistical Rethinking" p380 for further details.
  
  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 cumulative link function to model the ordered categorical variables.
      See "Statistical Rethinking" p380 for further details.
  
      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.
      """
  
      # get the predicted probabilities
      probs = self._get_probs(X_hat)
      # index probs based on the ordinal class
      gather_idx = (X[:, self.idx]).long().unsqueeze(dim=1)
      predicted_prob = probs.gather(dim=1, index=gather_idx).squeeze()
      # nll
      loss = -torch.log(predicted_prob)
  
      return torch.mean(loss)
  
file_path: causalnex/causalnex/structure/pytorch/dist_type/ordinal.py
imports: from copy import deepcopy
  import numpy
  import torch
  from sklearn.preprocessing import OrdinalEncoder
  from causalnex.structure.pytorch.dist_type._base import DistTypeBase
label_desc: Use image node_id 3 for calling the DistTypeOrdinal obj's underlying member method code with example usage: obj.loss(X, X_hat) and returns: torch