<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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