code: def categorical_accuracy(y_true, y_pred):
      y_true = ops.argmax(y_true, axis=-1)
  
      reshape_matches = False
      y_pred = ops.convert_to_tensor(y_pred)
      y_true = ops.convert_to_tensor(y_true, dtype=y_true.dtype)
  
      y_true_org_shape = ops.shape(y_true)
      y_pred_rank = len(y_pred.shape)
      y_true_rank = len(y_true.shape)
  
      # If the shape of y_true is (num_samples, 1), squeeze to (num_samples,)
      if (
          (y_true_rank is not None)
          and (y_pred_rank is not None)
          and (len(y_true.shape) == len(y_pred.shape))
      ):
          y_true = ops.squeeze(y_true, -1)
          reshape_matches = True
      y_pred = ops.argmax(y_pred, axis=-1)
  
      # If the predicted output and actual output types don't match, force cast
      # them to match.
      if y_pred.dtype != y_true.dtype:
          y_pred = ops.cast(y_pred, dtype=y_true.dtype)
      matches = ops.cast(ops.equal(y_true, y_pred), backend.floatx())
      if reshape_matches:
          matches = ops.reshape(matches, new_shape=y_true_org_shape)
      return matches
  
imports: from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.losses.loss import squeeze_to_same_rank
  from keras.metrics import reduction_metrics
label_desc: Use image node_id 3 for calling a global function with example usage: categorical_accuracy(y_true, y_pred) and returns: matches