code: def update(self, batch_cross_entropy: float, batch_num_valid: float):
      self._sum += batch_cross_entropy
      self._num_inst += batch_num_valid
  
imports: import logging
  import math
  from abc import ABC, abstractmethod
  from typing import Any, Dict, Optional, Tuple
  import torch
  import numpy
  from .None import constants
  from .None import utils
label_desc: Use image node_id 2 for calling the PerplexityMetric obj's underlying member method code with example usage: obj.update(batch_cross_entropy, batch_num_valid) without return types