code: def update(self, pred: str, target: str, category: str = None):
      if pred == target:
          self.correct += 1
      self.total += 1
      if category is None:
          return
      if category in self.categories:
          val = getattr(self, f"{category}_total")
          setattr(self, f"{category}_total", val + 1)
          if pred == target:
              val = getattr(self, f"{category}_correct")
              setattr(self, f"{category}_correct", val + 1)
      else:
          logging.warn(f"{category} is not in the pre-defined list")
  
imports: import logging
  import re
  import string
  from collections import Counter
  from typing import List, Union
  import torch
  from torchmetrics import Metric
label_desc: Use image node_id 2 for calling the ExactStringPerCategoryMatchMetric obj's underlying member method code with example usage: obj.update(pred, target, category) without return types