class_docstr: A deep-learning based Variational Monte Carlo method [1]_ for calculating the ab-initio
  solution of a many-electron system.
  
  This model must be pre-trained on the HF baseline and then can be used to improve on it using electronic interactions
  via the learned electron distance features. Ferminet models the orbital values using envelope functions and the
  calculated electron features, which can then be used to approximate the wavefunction for better sampling of electrons.
  
  Example
  -------
  >>> import numpy as np
  >>> import deepchem as dc
  >>> from deepchem.models.torch_models.ferminet import Ferminet
  >>> import torch
  >>> H2_molecule =  torch.Tensor([[0, 0, 0.748], [0, 0, 0]])
  >>> H2_charge = torch.Tensor([[1], [1]])
  >>> model = Ferminet(nucleon_pos=H2_molecule, nuclear_charge=H2_charge, spin=0, batch_size=1)
  >>> electron = np.random.rand(1, 2*3)
  >>> wavefunction = model.forward(electron)
  
  References
  ----------
  .. [1] Spencer, James S., et al. Better, Faster Fermionic Neural Networks. arXiv:2011.07125, arXiv, 13 Nov. 2020. arXiv.org, http://arxiv.org/abs/2011.07125.
class_docstr_tok: ["A","deep-learning","based","Variational","Monte","Carlo","method","[","1","]","_","for","calculating","the","ab-initio","solution","of","a","many-electron","system",".","This","model","must","be","pre-trained","on","the","HF","baseline","and","then","can","be","used","to","improve","on","it","using","electronic","interactions","via","the","learned","electron","distance","features",".","Ferminet","models","the","orbital","values","using","envelope","functions","and","the","calculated","electron","features",",","which","can","then","be","used","to","approximate","the","wavefunction","for","better","sampling","of","electrons",".","Example","--","--","--","-",">",">",">","import","numpy","as","np",">",">",">","import","deepchem","as","dc",">",">",">","from","deepchem.models.torch_models.ferminet","import","Ferminet",">",">",">","import","torch",">",">",">","H2_molecule","=","torch.Tensor","(","[","[","0",",","0",",","0.748","]",",","[","0",",","0",",","0","]","]",")",">",">",">","H2_charge","=","torch.Tensor","(","[","[","1","]",",","[","1","]","]",")",">",">",">","model","=","Ferminet","(","nucleon_pos=H2_molecule",",","nuclear_charge=H2_charge",",","spin=0",",","batch_size=1",")",">",">",">","electron","=","np.random.rand","(","1",",","2","*","3",")",">",">",">","wavefunction","=","model.forward","(","electron",")","References","--","--","--","--","--","..","[","1","]","Spencer",",","James","S.",",","et","al",".","Better",",","Faster","Fermionic","Neural","Networks",".","arXiv:2011.07125",",","arXiv",",","13","Nov.","2020.","arXiv.org",",","http",":","\/\/arxiv.org\/abs\/2011.07125","."]
docstr: Implements the loss function for both pretraining and the actual training parts.
  
  Parameters
  ----------
  psi_up_mo: List[Optional[np.ndarray]] (default [None])
      numpy array containing the sampled hartreee fock up-spin orbitals
  psi_down_mo: List[Optional[np.ndarray]] (default [None])
      numpy array containing the sampled hartreee fock down-spin orbitals
  pretrain: List[bool] (default [True])
      indicates whether the model is pretraining
docstr_tok: ["Implements","the","loss","function","for","both","pretraining","and","the","actual","training","parts",".","Parameters","--","--","--","--","--","psi_up_mo",":","List","[","Optional","[","np.ndarray","]","]","(","default","[","None","]",")","numpy","array","containing","the","sampled","hartreee","fock","up-spin","orbitals","psi_down_mo",":","List","[","Optional","[","np.ndarray","]","]","(","default","[","None","]",")","numpy","array","containing","the","sampled","hartreee","fock","down-spin","orbitals","pretrain",":","List","[","bool","]","(","default","[","True","]",")","indicates","whether","the","model","is","pretraining"]
code: def loss(
      self,
      psi_up_mo: List[Optional[np.ndarray]] = [None],
      psi_down_mo: List[Optional[np.ndarray]] = [None],
      pretrain: List[bool] = [True],
  ):
      """
      Implements the loss function for both pretraining and the actual training parts.
  
      Parameters
      ----------
      psi_up_mo: List[Optional[np.ndarray]] (default [None])
          numpy array containing the sampled hartreee fock up-spin orbitals
      psi_down_mo: List[Optional[np.ndarray]] (default [None])
          numpy array containing the sampled hartreee fock down-spin orbitals
      pretrain: List[bool] (default [True])
          indicates whether the model is pretraining
      """
      criterion = torch.nn.MSELoss()
      if pretrain[0]:
          psi_up_mo_torch = torch.from_numpy(psi_up_mo).unsqueeze(1)
          psi_down_mo_torch = torch.from_numpy(psi_down_mo).unsqueeze(1)
          self.running_diff = (
              self.running_diff.float()
              + criterion(
                  self.psi_up.float(), psi_up_mo_torch.float()
              ).float()
              + criterion(
                  self.psi_down.float(), psi_down_mo_torch.float()
              ).float()
          )
      else:
          energy = (
              self.calculate_electron_electron()
              - self.calculate_electron_nuclear()
              + self.nuclear_nuclear_potential
              + self.calculate_kinetic_energy()
          )
          return energy.detach()
  
imports: import logging
  from typing import List, Optional, Tuple
  from rdkit import Chem
  import numpy
  from deepchem.utils.molecule_feature_utils import ALLEN_ELECTRONEGATIVTY
  from deepchem.models.torch_models import TorchModel
  import torch
  from deepchem.models.torch_models.layers import FerminetElectronFeature, FerminetEnvelope
  from deepchem.utils.electron_sampler import ElectronSampler
label_desc: Use image node_id 3 for calling the Ferminet obj's underlying member method code with example usage: obj.loss(psi_up_mo, psi_down_mo, pretrain) and returns: energy