code: def stereo(self, mol_batch, mol_vec):
      stereo_cands = mol_batch["stereo_cand_graph_batch"]
      batch_idx = mol_batch["stereo_cand_batch_idx"]
      labels = mol_batch["stereo_cand_labels"]
      lengths = mol_batch["stereo_cand_lengths"]
  
      if len(labels) == 0:
          # Only one stereoisomer exists; do nothing
          return cuda(torch.tensor(0.0)), 1.0
  
      batch_idx = cuda(torch.LongTensor(batch_idx))
      stereo_cands = self.mpn(stereo_cands)
      stereo_cands = self.G_mean(stereo_cands)
      stereo_labels = mol_vec[batch_idx]
      scores = F.cosine_similarity(stereo_cands, stereo_labels)
  
      st, acc = 0, 0
      all_loss = []
      for label, le in zip(labels, lengths):
          cur_scores = scores[st : st + le]
          if cur_scores.data[label].item() >= cur_scores.max().item():
              acc += 1
          label = cuda(torch.LongTensor([label]))
          all_loss.append(
              F.cross_entropy(
                  cur_scores.view(1, -1), label, size_average=False
              )
          )
          st += le
  
      all_loss = sum(all_loss) / len(labels)
      return all_loss, acc / len(labels)
  
imports: import copy
  import rdkit.Chem
  import torch
  import torch.nn
  import torch.nn.functional
  from dgl import batch, unbatch
  from .chemutils import attach_mols_nx, copy_edit_mol, decode_stereo, enum_assemble_nx, set_atommap
  from .jtmpn import DGLJTMPN, mol2dgl_single
  from .jtnn_dec import DGLJTNNDecoder
  from .jtnn_enc import DGLJTNNEncoder
  from .mpn import DGLMPN, mol2dgl_single
  from .nnutils import cuda
label_desc: Use image node_id 7 for calling the DGLJTNNVAE obj's underlying member method code with example usage: obj.stereo(mol_batch, mol_vec) and returns: all_loss,  unknown, cuda,  int