class_docstr: Test loss functions.
class_docstr_tok: ["Test","loss","functions","."]
code: def test_get_positive_expectation(self):
      import numpy as np
      import torch
  
      from deepchem.models.losses import get_positive_expectation
  
      p_samples = torch.tensor([0.5, 1.0, -0.5, -1.0])
      measures = ["GAN", "JSD", "X2", "KL", "RKL", "DV", "H2", "W1"]
      expected_results = [
          np.array(-0.76866937),
          np.array(-0.07552214),
          np.array(0.625),
          np.array(1),
          np.array(-1.3353533),
          np.array(0),
          np.array(-0.33535326),
          np.array(0),
      ]
  
      for measure, expected in zip(measures, expected_results):
          result = (
              get_positive_expectation(p_samples, measure)
              .detach()
              .numpy()
          )
          assert np.allclose(result, expected, atol=1e-6)
  
imports: import unittest
  import numpy
  import pytest
  import deepchem
  import deepchem.models.losses
label_desc: Use image node_id 32 for calling the TestLosses obj's underlying member method code with example usage: obj.test_get_positive_expectation() without return types