code: def make_multi_class_loss_fn(label_vocabulary=None):
      """Returns multi class loss function."""
  
      def _labels_are_one_hot(labels, logits, label_vocabulary):
          if label_vocabulary:
              return False
          elif labels.dtype.is_integer:
              return False
          elif tf.squeeze(labels).shape == logits.shape:
              return True
          else:
              return False
  
      def _loss_fn(labels, logits, weights=1.0):
          """Cross entropy loss fn."""
  
          if _labels_are_one_hot(labels, logits, label_vocabulary):
              one_hot_labels = labels
          else:
              if label_vocabulary:
                  initializer = tf.lookup.KeyValueTensorInitializer(
                      keys=label_vocabulary,
                      values=range(len(label_vocabulary)),
                      name="class_id_lookup",
                      value_dtype=tf.int64,
                  )
                  table = tf.lookup.StaticVocabularyTable(
                      initializer, 1, name="lookup"
                  )
                  label_ids = table.lookup(labels)
              else:
                  label_ids = tf.squeeze(labels)
  
              if label_ids.dtype == tf.float32:
                  label_ids = tf.cast(label_ids, "int32")
              one_hot_labels = tf.one_hot(
                  indices=label_ids, depth=logits.shape[-1]
              )
  
          return tf.reduce_mean(
              input_tensor=tf.compat.v1.losses.softmax_cross_entropy(
                  onehot_labels=one_hot_labels,
                  logits=logits,
                  weights=weights,
              )
          )
  
      return _loss_fn
  
imports: import tensorflow.compat.v2
label_desc: Use image node_id 4 for calling a global function with example usage: make_multi_class_loss_fn(label_vocabulary) and returns: _loss_fn, tf, False, False, True, False