code: def stereo(self, mol_batch, mol_vec):
      stereo_cands, batch_idx = [], []
      labels = []
      for i, mol_tree in enumerate(mol_batch):
          cands = mol_tree.stereo_cands
          if len(cands) == 1:
              continue
          if mol_tree.smiles3D not in cands:
              cands.append(mol_tree.smiles3D)
          stereo_cands.extend(cands)
          batch_idx.extend([i] * len(cands))
          labels.append((cands.index(mol_tree.smiles3D), len(cands)))
  
      if len(labels) == 0:
          return create_var(torch.zeros(1)), 1.0
  
      batch_idx = create_var(torch.LongTensor(batch_idx))
      stereo_cands = self.mpn(mol2graph(stereo_cands))
      stereo_cands = self.G_mean(stereo_cands)
      stereo_labels = mol_vec.index_select(0, batch_idx)
      scores = torch.nn.CosineSimilarity()(stereo_cands, stereo_labels)
  
      st, acc = 0, 0
      all_loss = []
      for label, le in labels:
          cur_scores = scores.narrow(0, st, le)
          if cur_scores.data[label] >= cur_scores.max().data:
              acc += 1
          label = create_var(torch.LongTensor([label]))
          all_loss.append(
              self.stereo_loss(cur_scores.view(1, -1), label)
          )
          st += le
      all_loss = sum(all_loss) / len(labels)
      return all_loss, acc * 1.0 / len(labels)
  
imports: import torch
  import torch.nn
  from .mol_tree import Vocab, MolTree
  from .nnutils import create_var
  from .jtnn_enc import JTNNEncoder
  from .jtnn_dec import JTNNDecoder
  from .mpn import MPN, mol2graph
  from .jtmpn import JTMPN
  from .chemutils import enum_assemble, set_atommap, copy_edit_mol, attach_mols, atom_equal, decode_stereo
  import rdkit
  import rdkit.Chem
  from rdkit import DataStructs
  from rdkit.Chem import AllChem
  import copy
  import math
label_desc: Use image node_id 6 for calling the JTPropVAE obj's underlying member method code with example usage: obj.stereo(mol_batch, mol_vec) and returns: all_loss,  unknown, create_var,  int