class_docstr: An implementation of PGExplainer in
  `Parameterized Explainer for Graph Neural Network <https://arxiv.org/abs/2011.04573>`_.
  
  Args:
      model (:class:`torch.nn.Module`): The target model prepared to explain
      in_channels (:obj:`int`): Number of input channels for the explanation network
      explain_graph (:obj:`bool`): Whether to explain graph classification model (default: :obj:`True`)
      epochs (:obj:`int`): Number of epochs to train the explanation network
      lr (:obj:`float`): Learning rate to train the explanation network
      coff_size (:obj:`float`): Size regularization to constrain the explanation size
      coff_ent (:obj:`float`): Entropy regularization to constrain the connectivity of explanation
      t0 (:obj:`float`): The temperature at the first epoch
      t1(:obj:`float`): The temperature at the final epoch
      num_hops (:obj:`int`, :obj:`None`): The number of hops to extract neighborhood of target node
      (default: :obj:`None`)
  
  .. note: For node classification model, the :attr:`explain_graph` flag is False.
    If :attr:`num_hops` is set to :obj:`None`, it will be automatically calculated by calculating the
    :class:`torch_geometric.nn.MessagePassing` layers in the :attr:`model`.
class_docstr_tok: ["An","implementation","of","PGExplainer","in","`","Parameterized","Explainer","for","Graph","Neural","Network","<","https",":","\/\/arxiv.org\/abs\/2011.04573",">","`","_",".","Args",":","model","(",":","class",":","`","torch.nn.Module","`",")",":","The","target","model","prepared","to","explain","in_channels","(",":","obj",":","`","int","`",")",":","Number","of","input","channels","for","the","explanation","network","explain_graph","(",":","obj",":","`","bool","`",")",":","Whether","to","explain","graph","classification","model","(","default",":",":","obj",":","`","True","`",")","epochs","(",":","obj",":","`","int","`",")",":","Number","of","epochs","to","train","the","explanation","network","lr","(",":","obj",":","`","float","`",")",":","Learning","rate","to","train","the","explanation","network","coff_size","(",":","obj",":","`","float","`",")",":","Size","regularization","to","constrain","the","explanation","size","coff_ent","(",":","obj",":","`","float","`",")",":","Entropy","regularization","to","constrain","the","connectivity","of","explanation","t0","(",":","obj",":","`","float","`",")",":","The","temperature","at","the","first","epoch","t1","(",":","obj",":","`","float","`",")",":","The","temperature","at","the","final","epoch","num_hops","(",":","obj",":","`","int","`",",",":","obj",":","`","None","`",")",":","The","number","of","hops","to","extract","neighborhood","of","target","node","(","default",":",":","obj",":","`","None","`",")","..","note",":","For","node","classification","model",",","the",":","attr",":","`","explain_graph","`","flag","is","False",".","If",":","attr",":","`","num_hops","`","is","set","to",":","obj",":","`","None","`",",","it","will","be","automatically","calculated","by","calculating","the",":","class",":","`","torch_geometric.nn.MessagePassing","`","layers","in","the",":","attr",":","`","model","`","."]
code: def visualization(
      self,
      data: Data,
      edge_mask: Tensor,
      top_k: int,
      plot_utils: PlotUtils,
      words: Optional[list] = None,
      node_idx: int = None,
      vis_name: Optional[str] = None,
  ):
      if vis_name is None:
          vis_name = f"filename.png"
  
      data = data.to("cpu")
      edge_mask = edge_mask.to("cpu")
      if self.explain_graph:
          graph = to_networkx(data)
          if words is None:
              plot_utils.plot_soft_edge_mask(
                  graph,
                  edge_mask,
                  top_k=top_k,
                  un_directed=True,
                  words=words,
                  figname=vis_name,
              )
          else:
              plot_utils.plot_soft_edge_mask(
                  graph,
                  edge_mask,
                  top_k=top_k,
                  un_directed=True,
                  x=data.x,
                  figname=vis_name,
              )
      else:
          assert (
              node_idx is not None
          ), "visualization method doesn't get the target node index"
          x, edge_index, y, subset, kwargs = self.get_subgraph(
              node_idx=node_idx,
              x=data.x,
              edge_index=data.edge_index,
              y=data.y,
          )
          new_node_idx = torch.where(subset == node_idx)[0]
          new_data = Data(x=x, edge_index=edge_index)
          graph = to_networkx(new_data)
          plot_utils.plot_soft_edge_mask(
              graph,
              edge_mask,
              top_k=top_k,
              un_directed=True,
              y=y,
              node_idx=new_node_idx,
              figname=vis_name,
          )
  
imports: import tqdm
  import time
  import torch
  import numpy
  import torch.nn
  import networkx
  from math import sqrt
  from torch import Tensor
  from textwrap import wrap
  from torch.optim import Adam
  import matplotlib.pyplot
  import torch.nn.functional
  from torch_geometric.data import Data
  from torch_geometric.nn.conv import MessagePassing
  from torch_geometric.utils import to_networkx
  from torch_geometric.utils.num_nodes import maybe_num_nodes
  from typing import Tuple, List, Dict, Optional
  from .shapley import gnn_score, GnnNetsNC2valueFunc, GnnNetsGC2valueFunc, sparsity
  from torch_geometric.datasets import MoleculeNet
  from rdkit import Chem
label_desc: Use image node_id 12 for calling the PGExplainer obj's underlying member method code with example usage: obj.visualization(data, edge_mask, top_k, plot_utils, words, node_idx, vis_name) without return types