code: def test_loss_metric():
      metric = sockeye.loss.LossMetric(name="metric")
      assert metric.name == "metric"
      assert onp.isnan(metric.get())
      metric.update(loss=2, num_samples=2)
      assert metric.get() == 1.0
      metric.update(loss=2, num_samples=6)
      assert metric.get() == 0.5
      metric.reset()
      assert onp.isnan(metric.get())
  
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 2 for calling a global function with example usage: test_loss_metric() without return types