def METHOD_NAME(
    tmp_path, dataset_class, jsonl_file, use_alternative_index_mapping_dir, relative_index_fn,
):
    """Test for index_mapping_dir."""
    if relative_index_fn:
        jsonl_file = os.path.relpath(jsonl_file)
    else:
        jsonl_file = os.path.abspath(jsonl_file)
    if use_alternative_index_mapping_dir:
        index_mapping_dir = tmp_path / "subdir"
        dataset_class(dataset_paths=[jsonl_file], header_lines=0, index_mapping_dir=str(index_mapping_dir))
        # Index files should not be created in default location.
        assert not os.path.isfile(f"{jsonl_file}.idx.npy")
        assert not os.path.isfile(f"{jsonl_file}.idx.info")
        if relative_index_fn:
            # Remove leading ".." sequences.
            while jsonl_file.startswith(("../")):
                jsonl_file = jsonl_file.lstrip("../")
        idx_fn = f"{str(index_mapping_dir)}/{jsonl_file}.idx"
        assert os.path.isfile(f"{idx_fn}.npy")
        assert os.path.isfile(f"{idx_fn}.info")
    else:
        text_memmap_dataset.JSONLMemMapDataset(dataset_paths=[jsonl_file], header_lines=0)
        assert os.path.isfile(f"{jsonl_file}.idx.npy")
        assert os.path.isfile(f"{jsonl_file}.idx.info")