code: def test_smooth_l1_loss(self):
      layer = tl.SmoothL1Loss()
  
      model_outputs = np.array([[1.0, 1.0], [1.0, 2.0]])
      targets = np.array([[1.0, 1.0], [1.0, 0.0]])
      l1_dist = 2
  
      weights = np.array([[1.0, 1.0], [1.0, 0.0]])
      loss = layer([model_outputs, targets, weights])
      np.testing.assert_allclose(loss, 0.0)
  
      weights = np.array([[1.0, 0.0], [0.0, 1.0]])
      sum_weights = 2
  
      loss = layer([model_outputs, targets, weights])
      np.testing.assert_allclose(loss, (l1_dist - 0.5) / sum_weights)
  
      model_outputs = np.array([[1.0, 1.0], [1.0, 1.5]])
      targets = np.array([[1.0, 1.0], [1.0, 1.0]])
      l1_dist = 0.5
      loss = layer([model_outputs, targets, weights])
      np.testing.assert_allclose(loss, 0.5 * l1_dist**2 / sum_weights)
  
imports: from absl.testing import absltest
  import numpy
  import trax.layers
label_desc: Use image node_id 18 for calling the MetricsTest obj's underlying member method code with example usage: obj.test_smooth_l1_loss() without return types