code: def focal_loss(logits, labels, alpha, gamma=2, name="focal_loss"):
      """
      Focal loss for multi classification
      :param logits: A float32 tensor of shape [batch_size num_class].
      :param labels: A int32 tensor of shape [batch_size, num_class] or [batch_size].
      :param alpha: A 1D float32 tensor for focal loss alpha hyper-parameter
      :param gamma: A scalar for focal loss gamma hyper-parameter.
      Returns: A tensor of the same shape as `lables`
      """
      if len(labels.shape) == 1:
          labels = tf.one_hot(labels, logits.shape[-1])
      else:
          labels = labels
      labels = tf.to_float(labels)
  
      y_pred = tf.nn.softmax(logits, dim=-1)
      L = -labels * tf.log(y_pred)
      L *= alpha * ((1 - y_pred) ** gamma)
      loss = tf.reduce_sum(L)
  
      tf.summary.scalar(name, loss)
      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 7 for calling a global function with example usage: focal_loss(logits, labels, alpha, gamma, name) and returns: loss