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