class_docstr: Given a stochastic function with some batched sample statements and
  masking tensor, mask out some of the sample statements elementwise.
  
  :param fn: a stochastic function (callable containing Pyro primitive calls)
  :param torch.BoolTensor mask: a ``{0,1}``-valued masking tensor
      (1 includes a site, 0 excludes a site)
  :returns: stochastic function decorated with a :class:`~pyro.poutine.scale_messenger.MaskMessenger`
code: def __init__(self, mask: Union[bool, torch.BoolTensor]) -> None:
      if isinstance(mask, torch.Tensor):
          if mask.dtype != torch.bool:
              raise ValueError(
                  "Expected mask to be a BoolTensor but got {}".format(
                      type(mask)
                  )
              )
  
      elif mask not in (True, False):
          raise ValueError(
              "Expected mask to be a boolean but got {}".format(
                  type(mask)
              )
          )
      super().__init__()
      self.mask = mask
  
imports: from typing import TYPE_CHECKING, Union
  import torch
  from pyro.poutine.messenger import Messenger
label_desc: Use image node_id 1 to create a new MaskMessenger object from inherited base classes: Messenger with example: obj = MaskMessenger(mask)