code: def test_loss_block():
      b = DummyLoss(
          name="test",
          output_name="output",
          label_name="label",
          weight=2.0,
      )
      assert b.name == "test"
      assert b.output_name == "output"
      assert b.label_name == "label"
      assert b.weight == 2.0
  
      # check required outputs/labels not found
      with pytest.raises(sockeye.utils.SockeyeError) as _:
          b({"unknown_output": pt.zeros(1)}, {"label": pt.zeros(1)})
      with pytest.raises(sockeye.utils.SockeyeError) as _:
          b({"output": pt.zeros(1)}, {"unknown_label": pt.zeros(1)})
  
      metric = b.create_metric()
      assert isinstance(metric, sockeye.loss.LossMetric)
      assert metric.name == "test_metric"
  
      loss_out = b({"output": pt.ones(1)}, {"label": pt.ones(1)}).item()
      assert loss_out == 4.0
  
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 1 for calling a global function with example usage: test_loss_block() without return types