and then reducing this result depending on the argument "reduction"
   as
  if reduction == "mean":  # default
      loss = loss_pointwise.mean()
  elif reduction == "batchmean":  # mathematically correct
      loss = loss_pointwise.sum() / input.size(0)
  elif reduction == "sum":
      loss = loss_pointwise.sum()
  else:  # reduction == "none"
      loss = loss_pointwise

Note:
 As all the other losses in PyTorch, this function expects the
 first argument, "input", to be the output of the model (e.g. the
 neural network) and the second, "target", to be the observations
 in the dataset. This differs from the standard mathematical
 notation KL(P\ ||\ Q) where P denotes the distribution of the
 observations and Q denotes the model.

Warning:
 "reduction"*= "mean"* doesn't return the true KL divergence
 value, please use "reduction"*= "batchmean"* which aligns with
 the mathematical definition. In a future release, *"mean"* will
