code: def reduce_to_best_decode(metrics, reduce_func):
      """Extracts the best-decode from the metrics according to reduce_func.
  
      Args:
        metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames)
        reduce_func: callable, np.argmax or np.argmin.
      Returns:
        best_metrics: 2-D numpy array, shape=(num_samples, num_frames).
        best_decode_ind: 1-D numpy array, shape=(num_samples,)
      """
      num_videos = metrics.shape[1]
      # Take mean of the metric across the frames to approximate the video
      # closest to the ground truth.
      mean_across_frames = np.mean(metrics, axis=-1)
  
      # For every sample, use the decode that has a maximum mean-metric.
      best_decode_ind = reduce_func(mean_across_frames, axis=0)
      best_metrics = metrics[best_decode_ind, np.arange(num_videos), :]
      return best_metrics, best_decode_ind
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import numpy
  import six
  import tensorflow.compat.v1
label_desc: Use image node_id 11 for calling a global function with example usage: reduce_to_best_decode(metrics, reduce_func) and returns: best_metrics,  best_decode_ind