code: def test_loss_protocol(self) -> None:
      def _get_loss(loss_ins: ILoss) -> float:
          return loss_ins.run(forward_results, batch)[
              cflearn.LOSS_KEY
          ].item()
  
      predictions = torch.full([10, 1], 2.0)
      labels = torch.zeros([10, 1])
      forward_results = {cflearn.PREDICTIONS_KEY: predictions}
      batch = {cflearn.LABEL_KEY: labels}
      self.assertEqual(_get_loss(ILoss.make("mae", {})), 2.0)
      self.assertEqual(
          _get_loss(ILoss.make("mae", dict(reduction="sum"))), 20
      )
      mae = cflearn.MAELoss()
      self.assertEqual(mae(predictions, labels).mean().item(), 2.0)
      self.assertEqual(mae(predictions, labels).sum().item(), 20.0)
      # multi task
      multi_task_loss = ILoss.make(
          "multi_task", dict(loss_names=["mae", "mse"])
      )
      losses = multi_task_loss.run(forward_results, batch)
      self.assertEqual(losses[cflearn.LOSS_KEY].item(), 6.0)
      self.assertEqual(losses["mae"].item(), 2.0)
      self.assertEqual(losses["mse"].item(), 4.0)
  
file_path: carefree-learn/tests/test_protocol.py
imports: import torch
  import cflearn
  import unittest
  from typing import Any
  from cflearn.schema import ILoss
  from cflearn.pipeline import MLTrainingPipeline
label_desc: Use image node_id 3 for calling the TestProtocol obj's underlying member method code with example usage: obj.test_loss_protocol() and returns: loss_ins