class_docstr: Allow per-line lazy access to multiple text files using numpy memmap.
docstr: Return a string from binary memmap
code: def __getitem__(self, idx):
      """
      Return a string from binary memmap
      """
      if (idx >= len(self)) or (idx < 0):
          raise IndexError(
              f"Index {idx} if out of dataset range with {len(self)} samples"
          )
  
      # Identify the file containing the record
      file_id = np.digitize(idx, self.midx_bins, right=False)
      base_idx = self.midx_bins[file_id - 1] if file_id > 0 else 0
      file_idx = idx - base_idx + self._header_lines
      mdata, midx = self.mdata_midx_list[file_id]
      # load sample
      if file_idx == 0:
          i = 0
          j = midx[0]
      else:
          i = midx[file_idx - 1] + 1  # ignore newline
          j = midx[file_idx]
  
      # fetch sample from memmap
  
      try:
          sample = self._fetch_sample_from_memmap(mdata, i, j)
      except Exception as e:
          logging.error(f"Error while fetching sample from memmap: {e}")
          logging.error(
              f"file_id: {file_id}, file_idx: {file_idx}, i: {i}, j: {j}"
          )
          raise e
  
      # parse raw text (e.g., tokenize)
      try:
          data = self._build_data_from_text(sample)
      except Exception as e:
          logging.error(
              f"Error while building data from text, possible issue with sample expected format (see offending sample below): {e}"
          )
          logging.error(
              f"sample: {sample}, file_id: {file_id}, file_idx: {file_idx}, i: {i}, j: {j}"
          )
          raise e
  
      return data
  
imports: import datetime
  import json
  import multiprocessing
  import os
  import pickle
  import time
  from functools import partial
  from typing import Callable, List, Optional, Type
  import numpy
  import torch
  from nemo.core import Dataset
  from nemo.utils import AppState, logging
label_desc: Use image node_id 4 for calling the TextMemMapDataset obj's underlying member method code with example usage: obj.__getitem__(idx) and returns: data