class_docstr: Test loss functions.
class_docstr_tok: ["Test","loss","functions","."]
docstr: .
code: def test_VAE_ELBO_pytorch(self):
      """."""
      loss = losses.VAE_ELBO()
      logvar = torch.tensor([[1.0, 1.3], [0.6, 1.2]])
      mu = torch.tensor([[0.2, 0.7], [1.2, 0.4]])
      x = torch.tensor([[0.9, 0.4, 0.8], [0.3, 0, 1]])
      reconstruction_x = torch.tensor([[0.8, 0.3, 0.7], [0.2, 0, 0.9]])
      result = loss._create_pytorch_loss()(
          logvar, mu, x, reconstruction_x
      ).numpy()
      expected = [
          0.5
          * np.mean(
              [
                  0.04 + 1.0 - np.log(1e-20 + 1.0) - 1,
                  0.49 + 1.69 - np.log(1e-20 + 1.69) - 1,
              ]
          )
          - np.mean(
              np.array([0.9, 0.4, 0.8]) * np.log([0.8, 0.3, 0.7])
              + np.array([0.1, 0.6, 0.2]) * np.log([0.2, 0.7, 0.3])
          ),
          0.5
          * np.mean(
              [
                  1.44 + 0.36 - np.log(1e-20 + 0.36) - 1,
                  0.16 + 1.44 - np.log(1e-20 + 1.44) - 1,
              ]
          )
          - np.mean(
              np.array([0.3, 0, 1]) * np.log([0.2, 1e-20, 0.9])
              + np.array([0.7, 1, 0]) * np.log([0.8, 1, 0.1])
          ),
      ]
      assert np.allclose(expected, result)
  
imports: import unittest
  import numpy
  import pytest
  import deepchem
  import deepchem.models.losses
label_desc: Use image node_id 24 for calling the TestLosses obj's underlying member method code with example usage: obj.test_VAE_ELBO_pytorch() without return types