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:
      loss: loss function to be wrapped, this could be a loss class or an instance of a loss class.
      loss_args: arguments to the loss function's constructor if `loss` is a class.
      loss_kwargs: keyword arguments to the loss function's constructor if `loss` is a class.
docstr_tok: ["Args",":","loss",":","loss","function","to","be","wrapped",",","this","could","be","a","loss","class","or","an","instance","of","a","loss","class",".","loss_args",":","arguments","to","the","loss","function","'s","constructor","if","`","loss","`","is","a","class",".","loss_kwargs",":","keyword","arguments","to","the","loss","function","'s","constructor","if","`","loss","`","is","a","class","."]
code: def __init__(
      self,
      loss: Callable[[torch.Tensor, torch.Tensor], torch.Tensor]
      | _Loss,
      *loss_args: Any,
      **loss_kwargs: Any,
  ) -> None:
      """
      Args:
          loss: loss function to be wrapped, this could be a loss class or an instance of a loss class.
          loss_args: arguments to the loss function's constructor if `loss` is a class.
          loss_kwargs: keyword arguments to the loss function's constructor if `loss` is a class.
      """
      super().__init__()
      self.loss: Callable[
          [torch.Tensor, torch.Tensor], torch.Tensor
      ] = (
          loss(*loss_args, **loss_kwargs)
          if inspect.isclass(loss)
          else loss
      )
      if not callable(self.loss):
          raise ValueError("The loss function is not callable.")
  
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 1 to create a new MaskedLoss object from inherited base classes: _Loss with example: obj = MaskedLoss(loss)