code: def cross_entropy(
      logits,
      labels,
      input_length=None,
      label_length=None,
      smoothing=0.0,
      reduction=tf.losses.Reduction.SUM_BY_NONZERO_WEIGHTS,
  ):
      """
      cross entropy function for classfication and seq classfication
      :param, label_length, for seq task, this for target seq length, e.g. a b c </s>, 4
      """
      del input_length
  
      onehot_labels = tf.cond(
          pred=tf.equal(tf.rank(logits) - tf.rank(labels), 1),
          true_fn=lambda: tf.one_hot(
              labels, tf.shape(logits)[-1], dtype=tf.int32
          ),
          false_fn=lambda: labels,
      )
  
      if label_length is not None:
          max_len = tf.shape(logits)[1]
          weights = utils.len_to_mask(label_length, max_len)
      else:
          weights = 1.0
  
      loss = tf.losses.softmax_cross_entropy(
          onehot_labels=onehot_labels,
          logits=logits,
          weights=weights,
          label_smoothing=smoothing,
          reduction=reduction,
      )
  
      return loss
  
file_path: delta/delta/utils/loss/loss_utils.py
imports: import math
  import delta.compat
  import tensorflow_addons
  from delta import utils
  from delta.utils import ctc_utils
label_desc: Use image node_id 1 for calling a global function with example usage: cross_entropy(logits, labels, input_length, label_length, smoothing, reduction) and returns: loss