class_docstr: An abstract base class for implementing explainer algorithms.
docstr: "Post processes any mask to not include any attributions of
  elements not involved during message passing.
docstr_tok: ["``","Post","processes","any","mask","to","not","include","any","attributions","of","elements","not","involved","during","message","passing","."]
code: def _post_process_mask(
      mask: Optional[Tensor],
      hard_mask: Optional[Tensor] = None,
      apply_sigmoid: bool = True,
  ) -> Optional[Tensor]:
      r""" "Post processes any mask to not include any attributions of
      elements not involved during message passing.
      """
      if mask is None:
          return mask
  
      mask = mask.detach()
  
      if apply_sigmoid:
          mask = mask.sigmoid()
  
      if hard_mask is not None and mask.size(0) == hard_mask.size(0):
          mask[~hard_mask] = 0.0
  
      return mask
  
imports: from abc import abstractmethod
  from typing import Dict, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from torch import Tensor
  from torch_geometric.explain import Explanation, HeteroExplanation
  from torch_geometric.explain.config import ExplainerConfig, ModelConfig, ModelReturnType
  from torch_geometric.nn import MessagePassing
  from torch_geometric.typing import EdgeType, NodeType
  from torch_geometric.utils import k_hop_subgraph
label_desc: Use image node_id 6 for calling the ExplainerAlgorithm obj's underlying member method code with example usage: obj._post_process_mask(mask, hard_mask, apply_sigmoid) and returns: mask, mask