code: def to_bigdl_metric(metric, loss):
      metric = metric.lower()
      loss_str = (
          loss
          if isinstance(loss, six.string_types)
          else loss.__class__.__name__
      ).lower()
      if metric == "accuracy" or metric == "acc":
          if (
              loss_str == "sparse_categorical_crossentropy"
              or loss_str == "sparsecategoricalcrossentropy"
          ):
              return metrics.SparseCategoricalAccuracy()
          elif (
              loss_str == "categorical_crossentropy"
              or loss_str == "categoricalcrossentropy"
          ):
              return metrics.CategoricalAccuracy()
          elif (
              loss_str == "binary_crossentropy"
              or loss_str == "binarycrossentropy"
          ):
              return metrics.BinaryAccuracy()
          else:
              raise TypeError(
                  "Not supported combination: metric {} and loss {}".format(
                      metric, loss_str
                  )
              )
      elif metric == "top5accuracy" or metric == "top5acc":
          return metrics.Top5Accuracy()
      elif metric == "mae":
          return metrics.MAE()
      elif metric == "mse":
          return metrics.MSE()
      elif metric == "auc":
          return metrics.AUC()
      elif metric == "loss":
          return Loss(to_bigdl_criterion(loss_str))
      elif metric == "treennaccuracy":
          return TreeNNAccuracy()
      else:
          raise TypeError("Unsupported metric: %s" % metric)
  
imports: from bigdl.optim.optimizer import *
  from zoo.pipeline.api.keras.objectives import *
  from zoo.pipeline.api.keras import metrics
label_desc: Use image node_id 3 for calling a global function with example usage: to_bigdl_metric(metric, loss) and returns: metrics, metrics, metrics, metrics, metrics, metrics, metrics, Loss, TreeNNAccuracy