class_docstr: This class computes mean perplexity of distributions in the last dimension of inputs. It is a wrapper around
  :doc:`torch.distributions.Categorical.perplexity<pytorch:distributions>` method. You have to provide either 
  ``probs`` or ``logits`` to the :meth:`update` method. The class computes perplexities for distributions passed to 
  :meth:`update` method in ``probs`` or ``logits`` arguments and averages the perplexities. Reducing results between
  all workers is done via SUM operations.
  See `PyTorch Lightning Metrics <https://pytorch-lightning.readthedocs.io/en/stable/ecosystem/metrics.html>`_ for the metric usage instructions.
  
  Args:
      dist_sync_on_step:
          Synchronize metric state across processes at each ``forward()``
          before returning the value at the step.
      process_group:
          Specify the process group on which synchronization is called. default: ``None`` (which selects the entire
              world)
      validate_args:
          If ``True`` values of :meth:`update` method parameters are checked. ``logits`` has to not contain NaNs and
          ``probs`` last dim has to be valid probability distribution.
docstr: Updates :attr:`perplexities_sum` and :attr:`num_distributions`.
  Args:
      probs: A ``torch.Tensor`` which innermost dimension is valid probability distribution.
      logits: A ``torch.Tensor`` without NaNs.
docstr_tok: ["Updates",":","attr",":","`","perplexities_sum","`","and",":","attr",":","`","num_distributions","`",".","Args",":","probs",":","A","``","torch.Tensor","``","which","innermost","dimension","is","valid","probability","distribution",".","logits",":","A","``","torch.Tensor","``","without","NaNs","."]
code: def update(self, probs=None, logits=None):
      """
      Updates :attr:`perplexities_sum` and :attr:`num_distributions`.
      Args:
          probs: A ``torch.Tensor`` which innermost dimension is valid probability distribution.
          logits: A ``torch.Tensor`` without NaNs.
      """
      d = Categorical(
          None if probs is None else probs.detach(),
          None if logits is None else logits.detach(),
          validate_args=self.validate_args,
      )
      ppl = d.perplexity()
      self.num_distributions += ppl.numel()
      self.perplexities_sum += ppl.sum()
  
imports: import torch
  from torch.distributions.categorical import Categorical
  from torchmetrics import Metric
label_desc: Use image node_id 2 for calling the Perplexity obj's underlying member method code with example usage: obj.update(probs, logits) without return types