code: def _get_metric(prefix, key, topn=None, **kwargs):
      """Helper function to construct a metric."""
      name = "{}{}{}".format(prefix, key, "_%s" % topn if topn else "")
      return metrics.get(key, name=name, topn=topn, **kwargs)
  
imports: import abc
  import dataclasses
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  import tensorflow
  from tensorflow_ranking.python import data
  from tensorflow_ranking.python.keras import losses
  from tensorflow_ranking.python.keras import metrics
  from tensorflow_ranking.python.keras import model
  from tensorflow_ranking.python.keras import saved_model
  from tensorflow_ranking.python.keras import strategy_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _get_metric(prefix, key, topn) and returns: metrics