code: def _update(self):
          
          aps = []
          for k, v in self.records.items():
              recall, prec = self._recall_prec(v, self.counts[k])
              ap = self._average_precision(recall, prec)
              aps.append(ap)
              if self.num is not None and k < (self.num - 1):
                  self.sum_metric[k] = ap
                  self.num_inst[k] = 1
          if self.num is None:
              self.num_inst = 1
              self.sum_metric = np.mean(aps)
          else:
              self.num_inst[-1] = 1
              self.sum_metric[-1] = np.mean(aps)
docs: update num_inst and sum_metric