code: def test_index(self):
      chunk_size = 64
      stride = 32
      sizes = np.array([128, 256], dtype=np.int32)
      dtype = np.int64
      itemsize = dtype().itemsize
      index_file = "/tmp/test.idx"
      try:
          with MMapRetrievalIndexedDataset.Index.writer(
              index_file, dtype, False
          ) as index:
              index.write(sizes, chunk_size, stride=stride)
  
          index_load = MMapRetrievalIndexedDataset.Index(index_file)
          assert index_load.chunk_size == chunk_size
          assert not index_load.retrieval_db
          assert np.array_equal(index_load.sizes, sizes)
          assert np.array_equal(
              index_load._chunk_id_start,
              np.array(
                  [0, len(range(0, sizes[0] - chunk_size + 1, stride))],
                  dtype=np.int64,
              ),
          )
          add1 = [
              i * itemsize
              for i in list(range(0, sizes[0] - chunk_size + 1, stride))
          ]
          start = max(add1) + chunk_size * itemsize
          add2 = [
              i * itemsize + start
              for i in list(range(0, sizes[1] - chunk_size + 1, stride))
          ]
          addr = add1 + add2
          assert np.array_equal(
              index_load._chunk_address, np.array(addr, dtype=np.int64)
          )
          assert np.array_equal(
              index_load._pointers,
              np.array([0, sizes[0] * itemsize], dtype=np.int64),
          )
          assert len(index_load._chunk_address) == index_load.num_chunks
      finally:
          os.remove(index_file)
  
      chunk_size = 64
      stride = 64
      sizes = np.array([128, 256], dtype=np.int32)
      dtype = np.int64
      itemsize = dtype().itemsize
      index_file = "/tmp/test.idx"
      try:
          with MMapRetrievalIndexedDataset.Index.writer(
              index_file, dtype, False
          ) as index:
              index.write(sizes, chunk_size, stride=stride)
  
          index_load = MMapRetrievalIndexedDataset.Index(index_file)
          assert index_load.chunk_size == chunk_size
          assert not index_load.retrieval_db
          assert np.array_equal(index_load.sizes, sizes)
          assert np.array_equal(
              index_load._chunk_id_start,
              np.array(
                  [0, len(range(0, sizes[0] - chunk_size + 1, stride))],
                  dtype=np.int64,
              ),
          )
          add1 = [
              i * itemsize
              for i in list(range(0, sizes[0] - chunk_size + 1, stride))
          ]
          start = max(add1) + chunk_size * itemsize
          add2 = [
              i * itemsize + start
              for i in list(range(0, sizes[1] - chunk_size + 1, stride))
          ]
          addr = add1 + add2
          assert np.array_equal(
              index_load._chunk_address, np.array(addr, dtype=np.int64)
          )
          assert np.array_equal(
              index_load._pointers,
              np.array([0, sizes[0] * itemsize], dtype=np.int64),
          )
          assert len(index_load._chunk_address) == index_load.num_chunks
      finally:
          os.remove(index_file)
  
imports: import os
  import numpy
  import pytest
  import torch
  from numpy.testing import assert_array_equal
  from omegaconf import OmegaConf
  from scripts.nlp_language_modeling.build_knn_map_index import build_map, dedup
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_retrieval_dataset import KNNIndex, MMapRetrievalIndexedDataset, MMapRetrievalIndexedDatasetBuilder, merge_knn_files
  from nemo.collections.nlp.data.language_modeling.megatron.retro_dataset import RETRODataset
label_desc: Use image node_id 2 for calling the TestRetrievalIndexFiles obj's underlying member method code with example usage: obj.test_index() without return types