code: def get(
      key: str,
      name: Optional[str] = None,
      dtype: Optional[tf.dtypes.DType] = None,
      topn: Optional[int] = None,
      **kwargs: Dict[str, Any],
  ) -> tf.keras.metrics.Metric:
      """Factory method to get a list of ranking metrics.
  
      Example Usage:
      ```python
        metric = tfr.keras.metics.get(tfr.keras.metrics.RankingMetricKey.MRR)
      ```
      to get Mean Reciprocal Rank.
      ```python
        metric = tfr.keras.metics.get(tfr.keras.metrics.RankingMetricKey.MRR,
                                      topn=2)
      ```
      to get MRR@2.
  
      Args:
        key: An attribute of `RankingMetricKey`, defining which metric objects to
          return.
        name: Name of metrics.
        dtype: Dtype of the metrics.
        topn: Cutoff of how many items are considered in the metric.
        **kwargs: Keyword arguments for the metric object.
  
      Returns:
        A tf.keras.metrics.Metric. See `_RankingMetric` signature for more details.
  
      Raises:
        ValueError: If key is unsupported.
      """
      if not isinstance(key, str):
          raise ValueError("Input `key` needs to be string.")
  
      key_to_cls = {
          RankingMetricKey.MRR: MRRMetric,
          RankingMetricKey.ARP: ARPMetric,
          RankingMetricKey.PRECISION: PrecisionMetric,
          RankingMetricKey.MAP: MeanAveragePrecisionMetric,
          RankingMetricKey.NDCG: NDCGMetric,
          RankingMetricKey.DCG: DCGMetric,
          RankingMetricKey.ORDERED_PAIR_ACCURACY: OPAMetric,
          RankingMetricKey.HITS: HitsMetric,
      }
  
      metric_kwargs = {"name": name, "dtype": dtype}
      if topn:
          metric_kwargs.update({"topn": topn})
  
      if kwargs:
          metric_kwargs.update(kwargs)
  
      if key in key_to_cls:
          metric_cls = key_to_cls[key]
          metric_obj = metric_cls(**metric_kwargs)
      else:
          raise ValueError("Unsupported metric: {}".format(key))
  
      return metric_obj
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Any, Dict, List, Optional
  import tensorflow.compat.v2
  from tensorflow_ranking.python import metrics_impl
  from tensorflow_ranking.python.keras import utils
label_desc: Use image node_id 1 for calling a global function with example usage: get(key, name, dtype, topn) and returns: metric_obj