code: def test_shape(self, input_param, expected_val):
      size = [3, 3, 5, 5]
      label = torch.randint(low=0, high=2, size=size)
      label = torch.argmax(label, dim=1, keepdim=True)
      pred = torch.randn(size)
      result = MaskedLoss(**input_param)(pred, label, None)
      out = result.detach().cpu().numpy()
      self.assertTrue(np.allclose(out, expected_val[0]))
  
      mask = torch.randint(low=0, high=2, size=label.shape)
      result = MaskedLoss(**input_param)(pred, label, mask)
      out = result.detach().cpu().numpy()
      self.assertTrue(np.allclose(out, expected_val[1]))
  
file_path: MONAI/tests/test_masked_loss.py
imports: from __future__ import annotations
  import unittest
  import numpy
  import torch
  from parameterized import parameterized
  from monai.losses.dice import DiceFocalLoss, DiceLoss
  from monai.losses.spatial_mask import MaskedLoss
  from monai.utils import set_determinism
  from tests.utils import test_script_save
label_desc: Use image node_id 3 for calling the TestMaskedLoss obj's underlying member method code with example usage: obj.test_shape(input_param, expected_val) without return types