class_docstr: Test class for `Perplexity` metric.
docstr: Test dtype support of the metric on CPU.
docstr_tok: ["Test","dtype","support","of","the","metric","on","CPU","."]
code: def test_perplexity_dtypes_cpu(
      self, preds, target, ignore_index, dtype
  ):
      """Test dtype support of the metric on CPU."""
      if dtype == torch.half:
          with pytest.raises(
              RuntimeError,
              match="\"softmax_lastdim_kernel_impl\" not implemented for 'Half'",
          ):
              self.run_precision_test_cpu(
                  preds,
                  target,
                  Perplexity,
                  perplexity,
                  metric_args={"ignore_index": ignore_index},
                  dtype=dtype,
              )
      else:
          self.run_precision_test_cpu(
              preds,
              target,
              Perplexity,
              perplexity,
              metric_args={"ignore_index": ignore_index},
              dtype=dtype,
          )
  
file_path: torchmetrics/tests/unittests/text/test_perplexity.py
imports: from functools import partial
  import pytest
  import torch
  from torch.nn import functional
  from torchmetrics.functional.text.perplexity import perplexity
  from torchmetrics.text.perplexity import Perplexity
  from unittests.helpers.testers import MetricTester
  from unittests.text.inputs import MASK_INDEX, _logits_inputs_fp32, _logits_inputs_fp32_with_mask, _logits_inputs_fp64, _logits_inputs_fp64_with_mask
label_desc: Use image node_id 4 for calling the TestPerplexity obj's underlying member method code with example usage: obj.test_perplexity_dtypes_cpu(preds, target, ignore_index, dtype) without return types