class_docstr: Featurizer for MolGAN de-novo molecular generation [1]_.
  The default representation is in form of GraphMatrix object.
  It is wrapper for two matrices containing atom and bond type information.
  The class also provides reverse capabilities.
  
  Examples
  --------
  >>> import deepchem as dc
  >>> from rdkit import Chem
  >>> rdkit_mol, smiles_mol = Chem.MolFromSmiles('CCC'), 'C1=CC=CC=C1'
  >>> molecules = [rdkit_mol, smiles_mol]
  >>> featurizer = dc.feat.MolGanFeaturizer()
  >>> features = featurizer.featurize(molecules)
  >>> len(features) # 2 molecules
  2
  >>> type(features[0])
  <class 'deepchem.feat.molecule_featurizers.molgan_featurizer.GraphMatrix'>
  >>> molecules = featurizer.defeaturize(features) # defeaturization
  >>> type(molecules[0])
  <class 'rdkit.Chem.rdchem.Mol'>
docstr: Recreate RDKitMol from GraphMatrix object.
  Same featurizer need to be used for featurization and defeaturization.
  It only recreates bond and atom types, any kind of additional features
  like chirality or charge are not included.
  Therefore, any checks of type: original_smiles == defeaturized_smiles
  will fail on chiral or charged compounds.
  
  Parameters
  ----------
  graph_matrix: GraphMatrix
      GraphMatrix object.
  sanitize: bool, default True
      Should RDKit sanitization be included in the process.
  cleanup: bool, default True
      Splits salts and removes compounds with "*" atom types
  
  Returns
  -------
  mol: RDKitMol object
      RDKitMol object representing molecule.
docstr_tok: ["Recreate","RDKitMol","from","GraphMatrix","object",".","Same","featurizer","need","to","be","used","for","featurization","and","defeaturization",".","It","only","recreates","bond","and","atom","types",",","any","kind","of","additional","features","like","chirality","or","charge","are","not","included",".","Therefore",",","any","checks","of","type",":","original_smiles","==","defeaturized_smiles","will","fail","on","chiral","or","charged","compounds",".","Parameters","--","--","--","--","--","graph_matrix",":","GraphMatrix","GraphMatrix","object",".","sanitize",":","bool",",","default","True","Should","RDKit","sanitization","be","included","in","the","process",".","cleanup",":","bool",",","default","True","Splits","salts","and","removes","compounds","with","``","*","''","atom","types","Returns","--","--","--","-","mol",":","RDKitMol","object","RDKitMol","object","representing","molecule","."]
code: def _defeaturize(
      self,
      graph_matrix: GraphMatrix,
      sanitize: bool = True,
      cleanup: bool = True,
  ) -> RDKitMol:
      """
      Recreate RDKitMol from GraphMatrix object.
      Same featurizer need to be used for featurization and defeaturization.
      It only recreates bond and atom types, any kind of additional features
      like chirality or charge are not included.
      Therefore, any checks of type: original_smiles == defeaturized_smiles
      will fail on chiral or charged compounds.
  
      Parameters
      ----------
      graph_matrix: GraphMatrix
          GraphMatrix object.
      sanitize: bool, default True
          Should RDKit sanitization be included in the process.
      cleanup: bool, default True
          Splits salts and removes compounds with "*" atom types
  
      Returns
      -------
      mol: RDKitMol object
          RDKitMol object representing molecule.
  
      """
  
      try:
          from rdkit import Chem
      except ModuleNotFoundError:
          raise ImportError(
              "This method requires RDKit to be installed."
          )
  
      if not isinstance(graph_matrix, GraphMatrix):
          return None
  
      node_labels = graph_matrix.node_features
      edge_labels = graph_matrix.adjacency_matrix
  
      mol = Chem.RWMol()
  
      for node_label in node_labels:
          mol.AddAtom(Chem.Atom(self.atom_decoder[node_label]))
  
      for start, end in zip(*np.nonzero(edge_labels)):
          if start > end:
              mol.AddBond(
                  int(start),
                  int(end),
                  self.bond_decoder[edge_labels[start, end]],
              )
  
      if sanitize:
          try:
              Chem.SanitizeMol(mol)
          except Exception:
              mol = None
  
      if cleanup:
          try:
              smiles = Chem.MolToSmiles(mol)
              smiles = max(smiles.split("."), key=len)
              if "*" not in smiles:
                  mol = Chem.MolFromSmiles(smiles)
              else:
                  mol = None
          except Exception:
              mol = None
  
      return mol
  
file_path: deepchem/deepchem/feat/molecule_featurizers/molgan_featurizer.py
imports: import logging
  import numpy
  from deepchem.utils.typing import RDKitBond, RDKitMol, List
  from deepchem.feat.base_classes import MolecularFeaturizer
  from deepchem.utils.typing import OneOrMany
  from typing import Optional
label_desc: Use image node_id 3 for calling the MolGanFeaturizer obj's underlying member method code with example usage: obj._defeaturize(graph_matrix, sanitize, cleanup) and returns: mol, None