class_docstr: Test loss functions.
class_docstr_tok: ["Test","loss","functions","."]
docstr: .
code: def test_VAE_KLDivergence_tf(self):
      """."""
      loss = losses.VAE_KLDivergence()
      logvar = tf.constant([[1.0, 1.3], [0.6, 1.2]])
      mu = tf.constant([[0.2, 0.7], [1.2, 0.4]])
      result = loss._compute_tf_loss(logvar, mu).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,
              ]
          ),
          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,
              ]
          ),
      ]
      assert np.allclose(expected, result)
  
imports: import unittest
  import numpy
  import pytest
  import deepchem
  import deepchem.models.losses
label_desc: Use image node_id 25 for calling the TestLosses obj's underlying member method code with example usage: obj.test_VAE_KLDivergence_tf() without return types