code: def _get_mask_closure(mask: _torch.Tensor) -> _GradClosureType:
      def closure(grad: _torch.Tensor) -> _torch.Tensor:
          grad = _torch.where(mask, _torch.zeros_like(grad), grad)
          if grad.requires_grad:
              grad.register_hook(_get_mask_closure(mask))
          return grad
  
      return closure
  
imports: import abc
  import collections
  import copy
  import math
  import typing
  import warnings
  import torch
  from .None import patch
  from .None import utils
label_desc: Use image node_id 1 for calling a global function with example usage: _get_mask_closure(mask) and returns: closure, grad