class_docstr: Implements an cross-entropy expectation semiring.
  
  Computes both the log-values of two distributions and the running cross entropy between two distributions.
  
  Based on descriptions in:
  
  * Parameter estimation for probabilistic finite-state transducers :cite:`eisner2002parameter`
  * First-and second-order expectation semirings with applications to minimum-risk training on translation forests :cite:`li2009first`
  * Sample Selection for Statistical Grammar Induction :cite:`hwa2000samplesf`
code: def sum(xs, dim=-1):
      assert dim != 0
      d = dim - 1 if dim > 0 else dim
      part_p = torch.logsumexp(xs[0], dim=d)
      part_q = torch.logsumexp(xs[1], dim=d)
      log_sm_p = xs[0] - part_p.unsqueeze(d)
      log_sm_q = xs[1] - part_q.unsqueeze(d)
      sm_p = log_sm_p.exp()
      return torch.stack(
          (
              part_p,
              part_q,
              torch.sum(xs[2].mul(sm_p) - log_sm_q.mul(sm_p), dim=d),
          )
      )
  
imports: import torch
label_desc: Use image node_id 4 for calling the CrossEntropySemiring obj's underlying member method code with example usage: obj.sum(xs, dim) and returns: torch