code: def categorical_crossentropy(
      gt, pr, class_weights=1.0, class_indexes=None, **kwargs
  ):
      backend = kwargs["backend"]
  
      gt, pr = gather_channels(gt, pr, indexes=class_indexes, **kwargs)
  
      # scale predictions so that the class probas of each sample sum to 1
      axis = 3 if backend.image_data_format() == "channels_last" else 1
      pr /= backend.sum(pr, axis=axis, keepdims=True)
  
      # clip to prevent NaN's and Inf's
      pr = backend.clip(pr, backend.epsilon(), 1 - backend.epsilon())
  
      # calculate loss
      output = gt * backend.log(pr) * class_weights
      return -backend.mean(output)
  
file_path: segmentation_models/segmentation_models/base/functional.py
label_desc: Use image node_id 10 for calling a global function with example usage: categorical_crossentropy(gt, pr, class_weights, class_indexes) and returns: unknown