code: def crf_loss(y_true, y_pred):
      """General CRF loss function depending on the learning mode.
      # Arguments
          y_true: tensor with true targets.
          y_pred: tensor with predicted targets.
      # Returns
          If the CRF layer is being trained in the join mode, returns the negative
          log-likelihood. Otherwise returns the categorical crossentropy implemented
          by the underlying Keras backend.
      # About GitHub
          If you open an issue or a pull request about CRF, please
          add `cc @lzfelix` to notify Luiz Felix.
      """
      crf, idx = y_pred._keras_history[:2]
      if crf.learn_mode == "join":
          return crf_nll(y_true, y_pred)
      else:
          if crf.sparse_target:
              return keras.losses.sparse_categorical_crossentropy(
                  y_true, y_pred
              )
          else:
              return keras.losses.categorical_crossentropy(
                  y_true, y_pred
              )
  
imports: from __future__ import absolute_import, division
  from ....imports import *
label_desc: Use image node_id 2 for calling a global function with example usage: crf_loss(y_true, y_pred) and returns: crf_nll, keras, keras