class_docstr: Test calculate_statistic.
class_docstr_tok: ["Test","calculate_statistic","."]
docstr: Test calculate_statistic with input as probability vector.
docstr_tok: ["Test","calculate_statistic","with","input","as","probability","vector","."]
code: def test_calculate_statistic_prob_with_sample_weights(self):
      """Test calculate_statistic with input as probability vector."""
      is_logits = False
      prob = np.array([[0.1, 0.85, 0.05], [0.1, 0.5, 0.4]])
      labels = np.array([1, 2])
      sample_weight = np.array([1.0, 0.5])
  
      stat = amia.calculate_statistic(
          prob, labels, sample_weight, is_logits, "conf with prob"
      )
      np.testing.assert_allclose(stat, np.array([0.85, 0.4]))
  
      stat = amia.calculate_statistic(
          prob, labels, sample_weight, is_logits, "xe"
      )
      np.testing.assert_allclose(
          stat, np.array([0.16251893, 0.458145365])
      )
  
      stat = amia.calculate_statistic(
          prob, labels, sample_weight, is_logits, "logit"
      )
      np.testing.assert_allclose(
          stat, np.array([1.73460106, -0.40546511])
      )
  
      np.testing.assert_raises(
          ValueError,
          amia.calculate_statistic,
          prob,
          labels,
          None,
          is_logits,
          "conf with logit",
      )
      np.testing.assert_raises(
          ValueError,
          amia.calculate_statistic,
          prob,
          labels,
          None,
          is_logits,
          "hinge",
      )
  
imports: from absl.testing import absltest
  from absl.testing import parameterized
  import numpy
  from tensorflow_privacy.privacy.privacy_tests.membership_inference_attack import advanced_mia
label_desc: Use image node_id 4 for calling the TestCalculateStatistic obj's underlying member method code with example usage: obj.test_calculate_statistic_prob_with_sample_weights() without return types