def METHOD_NAME(
    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")