code: def _compute_percentile(
      name: str, timings: List[float], percentiles: Sequence[float]
  ) -> Dict[str, float]:
      ret = {}
  
      # By default, numpy's percentile function will interpolate between values,
      # but we want to snap to actual metrics that were recorded. For more
      # discussion of percentile interpolation, see:
      # https://numpy.org/doc/stable/reference/generated/numpy.percentile.html
      computed_percentiles = np.percentile(
          timings, percentiles, interpolation="lower"
      )
  
      # computed_percentiles is a sequence of floats with the percentile
      # results. We use enumerate to allow us to grab the index for each
      # computed percentile, so that we can grab the corresponding percentile
      # to use as the "name" when we turn these values into the metrics.
      for i, percentile_value in enumerate(computed_percentiles):
          percentile = percentiles[i]
  
          ret[f"p{percentile}"] = percentile_value
  
      # include the mean as well in addition to the percentiles passed in
      ret["avg"] = np.mean(timings)
      return ret
  
imports: import datetime
  import logging
  import os
  from collections import defaultdict
  from contextlib import contextmanager
  from time import perf_counter
  from typing import Any, Dict, Generator, List, Optional, Protocol, runtime_checkable, Sequence, Tuple, TypeVar
  import numpy
  import torch
  import torch.distributed
  from tabulate import tabulate
  from torchtnt.utils.distributed import PGWrapper
label_desc: Use image node_id 10 for calling a global function with example usage: _compute_percentile(name, timings, percentiles) and returns: ret