code: def testmAPMeter(self):
      mtr = meter.mAPMeter()
      target = torch.Tensor([0, 1, 0, 1])
      output = torch.Tensor([0.1, 0.2, 0.3, 4])
      weight = torch.Tensor([0.5, 1.0, 2.0, 0.1])
      mtr.add(output, target)
  
      ap = mtr.value()
      val = (
          1 * 1.0 / 1.0
          + 0 * 1.0 / 2.0
          + 2.0 * 1.0 / 3.0
          + 0 * 1.0 / 4.0
      ) / 2.0
      self.assertTrue(
          math.fabs(ap - val) < 0.01, msg="mAP test1 failed"
      )
  
      mtr.reset()
      mtr.add(output, target, weight)
      ap = mtr.value()
      val = (
          1 * 0.1 / 0.1 + 0 * 2.0 / 2.1 + 1.1 * 1 / 3.1 + 0 * 1.0 / 4.0
      ) / 2.0
      self.assertTrue(
          math.fabs(ap - val) < 0.01, msg="mAP test2 failed"
      )
  
      # Test multiple K's
      target = torch.Tensor([[0, 1, 0, 1], [0, 1, 0, 1]]).transpose(
          0, 1
      )
      output = torch.Tensor(
          [[0.1, 0.2, 0.3, 4], [4, 3, 2, 1]]
      ).transpose(0, 1)
      weight = torch.Tensor([[1.0, 0.5, 2.0, 3.0]]).transpose(0, 1)
      mtr.reset()
      mtr.add(output, target, weight)
      ap = mtr.value()
      self.assertTrue(
          math.fabs(
              ap
              - torch.Tensor(
                  [
                      (
                          1 * 3.0 / 3.0
                          + 0 * 3.0 / 5.0
                          + 3.5 * 1 / 5.5
                          + 0 * 3.5 / 6.5
                      )
                      / 2.0,
                      (
                          0 * 1.0 / 1.0
                          + 1 * 0.5 / 1.5
                          + 0 * 0.5 / 3.5
                          + 1 * 3.5 / 6.5
                      )
                      / 2.0,
                  ]
              ).mean()
          )
          < 0.01,
          msg="mAP test3 failed",
      )
  
      mtr.reset()
      mtr.add(output, target)
      ap = mtr.value()
      self.assertTrue(
          math.fabs(
              ap
              - torch.Tensor(
                  [
                      (
                          1 * 1.0
                          + 0 * 1.0 / 2.0
                          + 2 * 1.0 / 3.0
                          + 0 * 1.0 / 4.0
                      )
                      / 2.0,
                      (
                          0 * 1.0
                          + 1 * 1.0 / 2.0
                          + 0 * 1.0 / 3.0
                          + 2 * 1.0 / 4.0
                      )
                      / 2.0,
                  ]
              ).mean()
          )
          < 0.01,
          msg="mAP test4 failed",
      )
  
file_path: pywick/tests/test_meters.py
imports: import unittest
  import math
  import torch
  import pywick.meters
  import numpy
label_desc: Use image node_id 8 for calling the TestMeters obj's underlying member method code with example usage: obj.testmAPMeter() without return types