class_docstr: This is a wrapper class for the loss functions.  It allows for additional
  weighting masks to be applied to both input and target.
  
  See Also:
      - :py:class:`monai.losses.MaskedDiceLoss`
class_docstr_tok: ["This","is","a","wrapper","class","for","the","loss","functions",".","It","allows","for","additional","weighting","masks","to","be","applied","to","both","input","and","target",".","See","Also",":","-",":","py",":","class",":","`","monai.losses.MaskedDiceLoss","`"]
docstr: Args:
      input: the shape should be BNH[WD].
      target: the shape should be BNH[WD].
      mask: the shape should be B1H[WD] or 11H[WD].
docstr_tok: ["Args",":","input",":","the","shape","should","be","BNH","[","WD","]",".","target",":","the","shape","should","be","BNH","[","WD","]",".","mask",":","the","shape","should","be","B1H","[","WD","]","or","11H","[","WD","]","."]
code: def forward(
      self,
      input: torch.Tensor,
      target: torch.Tensor,
      mask: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      """
      Args:
          input: the shape should be BNH[WD].
          target: the shape should be BNH[WD].
          mask: the shape should be B1H[WD] or 11H[WD].
      """
      if mask is None:
          warnings.warn("No mask value specified for the MaskedLoss.")
          return self.loss(input, target)
  
      if input.dim() != mask.dim():
          warnings.warn(
              f"Dim of input ({input.shape}) is different from mask ({mask.shape})."
          )
      if input.shape[0] != mask.shape[0] and mask.shape[0] != 1:
          raise ValueError(
              f"Batch size of mask ({mask.shape}) must be one or equal to input ({input.shape})."
          )
      if target.dim() > 1:
          if mask.shape[1] != 1:
              raise ValueError(
                  f"Mask ({mask.shape}) must have only one channel."
              )
          if input.shape[2:] != mask.shape[2:]:
              warnings.warn(
                  f"Spatial size of input ({input.shape}) is different from mask ({mask.shape})."
              )
      return self.loss(input * mask, target * mask)
  
file_path: MONAI/monai/losses/spatial_mask.py
imports: from __future__ import annotations
  import inspect
  import warnings
  from collections.abc import Callable
  from typing import Any, Optional
  import torch
  from torch.nn.modules.loss import _Loss
label_desc: Use image node_id 2 for calling the MaskedLoss obj's underlying member method code with example usage: obj.forward(input, target, mask) and returns: self, self