code: def _mask_fn(fn, mask):
      if mask is not None:
          mask = torch.as_tensor(
              mask
          )  # FIXME support mask=False in funsor.distributions
          fn = fn.mask(mask)
      return fn
  
file_path: pyro/pyro/contrib/funsor/handlers/trace_messenger.py
imports: import funsor
  import torch
  from pyro.contrib.funsor.handlers.primitives import to_funsor
  from pyro.contrib.funsor.handlers.runtime import _DIM_STACK
  from pyro.poutine.subsample_messenger import _Subsample
  from pyro.poutine.trace_messenger import TraceMessenger
label_desc: Use image node_id 1 for calling a global function with example usage: _mask_fn(fn, mask) and returns: fn