code: def test_loss(self):
      cross_entropy = nn.CrossEntropyLoss()
  
      criterion = MaskedCrossEntropy(mask="new")
      criterion.adaptation([1, 2, 3, 4])
      criterion.adaptation([5, 6, 7])
  
      mb_y = torch.tensor([5, 5, 6, 7, 6])
  
      new_pred = torch.rand(5, 8)
      new_pred_new = new_pred[
          :, criterion.current_mask(new_pred.shape[1])
      ]
  
      loss1 = criterion(new_pred, mb_y)
      loss2 = cross_entropy(new_pred_new, mb_y - 5)
  
      criterion.mask = "seen"
      loss3 = criterion(new_pred, mb_y)
  
      self.assertAlmostEqual(float(loss1), float(loss2), places=5)
      self.assertNotAlmostEqual(float(loss1), float(loss3), places=5)
  
file_path: avalanche/tests/training/test_losses.py
imports: import unittest
  import torch
  import torch.nn
  from avalanche.training.losses import ICaRLLossPlugin, MaskedCrossEntropy
label_desc: Use image node_id 1 for calling the TestMaskedCrossEntropy obj's underlying member method code with example usage: obj.test_loss() without return types