class_docstr: A combiner which computes categorical cross entropy.
code: def _cross_entropy(
      self,
      label: np.ndarray,
      prediction: np.ndarray,
  ) -> float:
      # smooth labels
      num_classes = prediction.shape[0]
      label = (
          label * (1.0 - self._label_smoothing)
          + self._label_smoothing / num_classes
      )
  
      if self._from_logits:
          # Let z_i be the logits of probability p_i
          # z_i = log( p_i / sum_(j!=i) p_j )
          # p_i = exp(z_i) / sum(exp(z))
          prediction = np.exp(prediction)
      # Normalize prediction probability to 1
      prediction /= np.sum(prediction)
  
      # It assumes each row is a single prediction and each column is a class.
      # The reduction on axis -1 is a classwise reduction.
      categorical_cross_entropy = -np.sum(
          np.multiply(label, np.ma.log(prediction))
      )
  
      # The np.item method makes sure the result is a one element numpy array and
      # returns the single element as a float.
      return metric_util.safe_to_scalar(categorical_cross_entropy)
  
imports: import abc
  import dataclasses
  from typing import Iterable, Optional, Dict
  import apache_beam
  import numpy
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
label_desc: Use image node_id 1 for calling the _CategoricalCrossEntropyCombiner obj's underlying member method code with example usage: obj._cross_entropy(label, prediction) and returns: metric_util