class_docstr: The method class for GraphEBM algorithm proposed in the paper `GraphEBM: Molecular Graph Generation with Energy-Based Models <https://arxiv.org/abs/2102.00546>`_. This class provides interfaces for running random generation, goal-directed generation (including property
  optimization and constrained optimization), and compositional generation with GraphEBM algorithm. Please refer to the `example codes <https://github.com/divelab/DIG/tree/dig-stable/examples/ggraph/GraphEBM>`_ for usage examples.
  
  Args:
      n_atom (int): Maximum number of atoms.
      n_atom_type (int): Number of possible atom types.
      n_edge_type (int): Number of possible bond types.
      hidden (int): Hidden dimensions.
      device (torch.device, optional): The device where the model is deployed.
class_docstr_tok: ["The","method","class","for","GraphEBM","algorithm","proposed","in","the","paper","`","GraphEBM",":","Molecular","Graph","Generation","with","Energy-Based","Models","<","https",":","\/\/arxiv.org\/abs\/2102.00546",">","`","_",".","This","class","provides","interfaces","for","running","random","generation",",","goal-directed","generation","(","including","property","optimization","and","constrained","optimization",")",",","and","compositional","generation","with","GraphEBM","algorithm",".","Please","refer","to","the","`","example","codes","<","https",":","\/\/github.com\/divelab\/DIG\/tree\/dig-stable\/examples\/ggraph\/GraphEBM",">","`","_","for","usage","examples",".","Args",":","n_atom","(","int",")",":","Maximum","number","of","atoms",".","n_atom_type","(","int",")",":","Number","of","possible","atom","types",".","n_edge_type","(","int",")",":","Number","of","possible","bond","types",".","hidden","(","int",")",":","Hidden","dimensions",".","device","(","torch.device",",","optional",")",":","The","device","where","the","model","is","deployed","."]
code: def __init__(
      self, n_atom, n_atom_type, n_edge_type, hidden, device=None
  ):
      super(GraphEBM, self).__init__()
      if device is None:
          self.device = torch.device(
              "cuda" if torch.cuda.is_available() else "cpu"
          )
      else:
          self.device = device
      self.energy_function = EnergyFunc(
          n_atom_type, hidden, n_edge_type
      ).to(self.device)
      self.n_atom = n_atom
      self.n_atom_type = n_atom_type
      self.n_edge_type = n_edge_type
  
imports: import time
  import os
  import copy
  import torch
  from torch.optim import Adam
  from tqdm import tqdm
  from rdkit import Chem
  from dig.ggraph.method import Generator
  from dig.ggraph.utils import gen_mol_from_one_shot_tensor
  from dig.ggraph.utils import qed, calculate_min_plogp, reward_target_molecule_similarity
  from .energy_func import EnergyFunc
  from .util import rescale_adj, requires_grad, clip_grad
label_desc: Use image node_id 1 to create a new GraphEBM object from inherited base classes: Generator with example: obj = GraphEBM(n_atom, n_atom_type, n_edge_type, hidden, device)