docstr: Thresholds the explanation masks according to the thresholding
  method.
  
  Args:
      *args: Arguments passed to :class:`ThresholdConfig`.
      **kwargs: Keyword arguments passed to :class:`ThresholdConfig`.
docstr_tok: ["Thresholds","the","explanation","masks","according","to","the","thresholding","method",".","Args",":","*","args",":","Arguments","passed","to",":","class",":","`","ThresholdConfig","`",".","*","*","kwargs",":","Keyword","arguments","passed","to",":","class",":","`","ThresholdConfig","`","."]
code: def threshold(
      self,
      *args,
      **kwargs,
  ) -> Union["Explanation", "HeteroExplanation"]:
      """Thresholds the explanation masks according to the thresholding
      method.
  
      Args:
          *args: Arguments passed to :class:`ThresholdConfig`.
          **kwargs: Keyword arguments passed to :class:`ThresholdConfig`.
      """
      threshold_config = ThresholdConfig.cast(*args, **kwargs)
  
      if threshold_config is None:
          return self
  
      # Avoid modification of the original explanation:
      out = copy.copy(self)
  
      for store in out.node_stores:
          store.node_mask = self._threshold_mask(
              store.get("node_mask"), threshold_config
          )
  
      for store in out.edge_stores:
          store.edge_mask = self._threshold_mask(
              store.get("edge_mask"), threshold_config
          )
  
      return out
  
imports: import copy
  from typing import Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch_geometric.data.data import Data, warn_or_raise
  from torch_geometric.data.hetero_data import HeteroData
  from torch_geometric.explain.config import ThresholdConfig, ThresholdType
  from torch_geometric.typing import EdgeType, NodeType
  from torch_geometric.visualization import visualize_graph
label_desc: Use image node_id 4 for calling the ExplanationMixin obj's underlying member method code with example usage: obj.threshold() and returns: out, self