class_docstr: The Synthetic datasets used in
  `Parameterized Explainer for Graph Neural Network <https://arxiv.org/abs/2011.04573>`_.
  It takes Barabási–Albert(BA) graph or balance tree as base graph
  and randomly attachs specific motifs to the base graph.
  
  Args:
      root (:obj:`str`): Root data directory to save datasets
      name (:obj:`str`): The name of the dataset. Including :obj:`BA_shapes`, BA_grid,
      transform (:obj:`Callable`, :obj:`None`): A function/transform that takes in an
          :class:`torch_geometric.data.Data` object and returns a transformed
          version. The data object will be transformed before every access.
          (default: :obj:`None`)
      pre_transform (:obj:`Callable`, :obj:`None`):  A function/transform that takes in
          an :class:`torch_geometric.data.Data` object and returns a
          transformed version. The data object will be transformed before
          being saved to disk. (default: :obj:`None`)
class_docstr_tok: ["The","Synthetic","datasets","used","in","`","Parameterized","Explainer","for","Graph","Neural","Network","<","https",":","\/\/arxiv.org\/abs\/2011.04573",">","`","_",".","It","takes","Barab\u00e1si\u2013Albert","(","BA",")","graph","or","balance","tree","as","base","graph","and","randomly","attachs","specific","motifs","to","the","base","graph",".","Args",":","root","(",":","obj",":","`","str","`",")",":","Root","data","directory","to","save","datasets","name","(",":","obj",":","`","str","`",")",":","The","name","of","the","dataset",".","Including",":","obj",":","`","BA_shapes","`",",","BA_grid",",","transform","(",":","obj",":","`","Callable","`",",",":","obj",":","`","None","`",")",":","A","function\/transform","that","takes","in","an",":","class",":","`","torch_geometric.data.Data","`","object","and","returns","a","transformed","version",".","The","data","object","will","be","transformed","before","every","access",".","(","default",":",":","obj",":","`","None","`",")","pre_transform","(",":","obj",":","`","Callable","`",",",":","obj",":","`","None","`",")",":","A","function\/transform","that","takes","in","an",":","class",":","`","torch_geometric.data.Data","`","object","and","returns","a","transformed","version",".","The","data","object","will","be","transformed","before","being","saved","to","disk",".","(","default",":",":","obj",":","`","None","`",")"]
code: def gen_motif_edge_mask(self, data, node_idx=0, num_hops=3):
      if self.name in ["ba_2motifs"]:
          return torch.logical_and(
              data.edge_index[0] >= 20, data.edge_index[1] >= 20
          )
      elif self.name in [
          "ba_shapes",
          "ba_community",
          "tree_grid",
          "tree_cycle",
      ]:
          """selection in a loop way to fetch all the nodes in the connected motifs"""
          if data.y[node_idx] == 0:
              return torch.zeros_like(data.edge_index[0]).type(
                  torch.bool
              )
          connected_motif_nodes = set()
          edge_label_matrix = (
              data.edge_label_matrix + data.edge_label_matrix.T
          )
          edge_index = data.edge_index.to("cpu")
          if isinstance(node_idx, torch.Tensor):
              connected_motif_nodes.add(node_idx.item())
          else:
              connected_motif_nodes.add(node_idx)
          for _ in range(num_hops):
              append_node = set()
              for node in connected_motif_nodes:
                  append_node.update(
                      tuple(
                          torch.where(edge_label_matrix[node] != 0)[
                              0
                          ].tolist()
                      )
                  )
              connected_motif_nodes.update(append_node)
          connected_motif_nodes_tensor = torch.Tensor(
              list(connected_motif_nodes)
          )
          frm_mask = (
              edge_index[0].unsqueeze(1)
              - connected_motif_nodes_tensor.unsqueeze(0)
              == 0
          ).any(dim=1)
          to_mask = (
              edge_index[1].unsqueeze(1)
              - connected_motif_nodes_tensor.unsqueeze(0)
              == 0
          ).any(dim=1)
          return torch.logical_and(frm_mask, to_mask)
  
imports: import os
  import torch
  import pickle
  import numpy
  import os.path
  import tqdm
  from torch_geometric.utils import dense_to_sparse
  from torch_geometric.data import Data, InMemoryDataset, download_url, extract_zip
  from torch_geometric.data.dataset import files_exist
  import shutil
label_desc: Use image node_id 9 for calling the SynGraphDataset obj's underlying member method code with example usage: obj.gen_motif_edge_mask(data, node_idx, num_hops) and returns: torch, torch, torch