class_docstr: XCollector is a data collector which takes processed related prediction probabilities to calculate Fidelity+
  and Fidelity-.
  
  Args:
      sparsity (float): The Sparsity is use to transform the soft mask to a hard one.
  
  .. note::
      For more examples, see `benchmarks/xgraph
      <https://github.com/divelab/DIG/tree/dig/benchmarks/xgraph>`_.
docstr: The function is used to collect related data. After collection, we can call fidelity, fidelity_inv, sparsity
  to calculate their values.
  
  Args:
      masks (list): It is a list of edge-level explanation for each class.
      related_preds (list): It is a list of dictionary for each class where each dictionary
      includes 4 type predicted probabilities and sparsity.
      label (int): The ground truth label. (default: 0)
docstr_tok: ["The","function","is","used","to","collect","related","data",".","After","collection",",","we","can","call","fidelity",",","fidelity_inv",",","sparsity","to","calculate","their","values",".","Args",":","masks","(","list",")",":","It","is","a","list","of","edge-level","explanation","for","each","class",".","related_preds","(","list",")",":","It","is","a","list","of","dictionary","for","each","class","where","each","dictionary","includes","4","type","predicted","probabilities","and","sparsity",".","label","(","int",")",":","The","ground","truth","label",".","(","default",":","0",")"]
code: def collect_data(
      self, masks: List[Tensor], related_preds: dir, label: int = 0
  ) -> None:
      r"""
      The function is used to collect related data. After collection, we can call fidelity, fidelity_inv, sparsity
      to calculate their values.
  
      Args:
          masks (list): It is a list of edge-level explanation for each class.
          related_preds (list): It is a list of dictionary for each class where each dictionary
          includes 4 type predicted probabilities and sparsity.
          label (int): The ground truth label. (default: 0)
      """
  
      if (
          self.__fidelity is not None
          or self.__fidelity_inv is not None
          or self.__accuracy is not None
          or self.__stability is not None
      ):
          (
              self.__fidelity,
              self.__fidelity_inv,
              self.__accuracy,
              self.__stability,
          ) = (None, None, None, None)
          print(
              f"#W#Called collect_data() after calculate explainable metrics."
          )
  
      if not np.isnan(label):
          for key, value in related_preds[label].items():
              self.__related_preds[key].append(value)
          for key in self.__related_preds.keys():
              if key not in related_preds[0].keys():
                  self.__related_preds[key].append(None)
          self.__targets.append(label)
          self.masks.append(masks)
  
imports: import torch
  import torch.nn
  from typing import List, Union
  from torch import Tensor
  import numpy
  from torch_geometric.data.data import Data
  from torch_geometric.nn import MessagePassing
label_desc: Use image node_id 4 for calling the XCollector obj's underlying member method code with example usage: obj.collect_data(masks, related_preds, label) without return types