code: def request_profiling_pytorch_timing_metrics(
      trial_id: int, metric_name: str, accumulated: bool = False
  ) -> None:
      def validate_timing_batch(
          batch: Dict[str, Any], batch_idx: int
      ) -> int:
          values = batch["values"]
          batches = batch["batches"]
          num_values = len(values)
          num_batch_indexes = len(batches)
          num_timestamps = len(batch["timestamps"])
          if (
              num_values != num_batch_indexes
              or num_batch_indexes != num_timestamps
          ):
              pytest.fail(
                  f"mismatched slices: not ({num_values} == {num_batch_indexes} == {num_timestamps})"
              )
  
          if not any(values):
              pytest.fail(
                  f"received bad batch, something went wrong: {batch}"
              )
  
          if batches[0] != batch_idx:
              pytest.fail(
                  f"batch did not start at correct batch, {batches[0]} != {batch_idx}: {batch}"
              )
  
          # Check batches are monotonic with no gaps.
          if not all(x + 1 == y for x, y in zip(batches, batches[1:])):
              pytest.fail(f"skips in batches sampled: {batch}")
  
          # 10 is just a threshold at which it would be really strange for a batch to be monotonic.
          if (
              accumulated
              and len(values) > 10
              and all(x < y for x, y in zip(values, values[1:]))
          ):
              pytest.fail(
                  f"per batch accumulated metric was monotonic, which is really fishy: {batch}"
              )
  
          return int(batches[-1]) + 1
  
      with api.get(
          conf.make_master_url(),
          "api/v1/trials/{}/profiler/metrics?{}".format(
              trial_id,
              to_query_params(PROFILER_METRIC_TYPE_TIMING, metric_name),
          ),
          stream=True,
      ) as r:
          batch_idx = 0
          have_batch = False
          for line in r.iter_lines():
              batch = json.loads(line)["result"]["batch"]
              batch_idx = validate_timing_batch(batch, batch_idx)
              have_batch = True
          if not have_batch:
              pytest.fail("no batch metrics at all")
  
file_path: determined/e2e_tests/tests/experiment/test_profiling.py
imports: import json
  import tempfile
  from typing import Any, Dict, Optional, Sequence
  from urllib.parse import urlencode
  import pytest
  from determined.common import api, util
  from determined.common.api import authentication, bindings, certs
  from tests import config
  from tests import experiment
label_desc: Use image node_id 4 for calling a global function with example usage: request_profiling_pytorch_timing_metrics(trial_id, metric_name, accumulated) and returns: unknown