code: def test_perplexity_metric():
      ppl = sockeye.loss.PerplexityMetric()
      assert ppl.name == C.PERPLEXITY
      ces = [2.0, 1.4, 5.2]
      for ce in ces:
          ppl.update(ce, 1)
      expected_ppl = math.exp(sum(ces) / len(ces))
      assert onp.isclose(ppl.get(), expected_ppl)
  
file_path: sockeye/test/unit/test_loss.py
imports: import math
  import numpy
  import pytest
  import torch
  import sockeye.constants
  import sockeye.loss
  import sockeye.model
  import sockeye.utils
label_desc: Use image node_id 6 for calling a global function with example usage: test_perplexity_metric() without return types