class_docstr: Test that build_transform is able to build torch losses correctly.
code: def _test_loss(self, config, output, target, expected_loss):
      # test that we are able to build losses from torch.nn.modules.loss
      # and that they work correctly
  
      crit = build_loss(config)
  
      # test that the weights are set correctly
      self.assertAlmostEqual(crit.weight.numpy().tolist(), [1.0, 1.0])
  
      # test that the loss is computed correctly
      self.assertAlmostEqual(crit(output, target).item(), expected_loss)
  
      # verify ignore index works
      if "ignore_index" in config:
          if get_torch_version() < [1, 11]:
              self.assertAlmostEqual(
                  crit(output, torch.tensor([-1])).item(), 0.0
              )
          else:
              self.assertTrue(
                  torch.isnan(crit(output, torch.tensor([-1]))).item()
              )
  
file_path: ClassyVision/test/losses_test.py
imports: import unittest
  import torch
  from classy_vision.generic.util import get_torch_version
  from classy_vision.losses import build_loss
label_desc: Use image node_id 1 for calling the CriterionsTest obj's underlying member method code with example usage: obj._test_loss(config, output, target, expected_loss) without return types