class_docstr: analogous to fairseq.data.indexed_dataset.IndexedCachedDataset.
  Support loading .idx + .bin as fairseq does and also .npz. In self
  initializer if
  (1) path is passed in: call the initializer of parent class and loads
  idx + bin from the path.
  (2) path is None: Initialize an empty class. Call load(path) to load
  .npz data.
  When self.is_npz=True, use the implementation in this class which overrides
  parent methods. Otherwise use parent functions in fairseq.
class_docstr_tok: ["analogous","to","fairseq.data.indexed_dataset.IndexedCachedDataset",".","Support","loading",".idx","+",".bin","as","fairseq","does","and","also",".npz",".","In","self","initializer","if","(","1",")","path","is","passed","in",":","call","the","initializer","of","parent","class","and","loads","idx","+","bin","from","the","path",".","(","2",")","path","is","None",":","Initialize","an","empty","class",".","Call","load","(","path",")","to","load",".npz","data",".","When","self.is_npz=True",",","use","the","implementation","in","this","class","which","overrides","parent","methods",".","Otherwise","use","parent","functions","in","fairseq","."]
code: def load(self, path, num_examples_limit: Optional[int] = None):
      with PathManager.open(path, "rb") as f:
          npz = np.load(f)
  
          # For big input data, we don't want the cpu to OOM.
          # Therefore, we are loading the huge buffer array into disc
          # and reading it from disc instead of memory.
          if npz["buffer"].nbytes > ARRAY_SIZE_LIMIT_FOR_MEMORY:
              self.buffer = np.memmap(
                  tempfile.NamedTemporaryFile().name,
                  dtype="float32",
                  mode="w+",
                  shape=npz["buffer"].shape,
              )
              self.buffer[:] = npz["buffer"][:]
          else:
              self.buffer = npz["buffer"]
          self.offsets = npz["offsets"]
  
      if (
          num_examples_limit is not None
          and len(self.offsets) > num_examples_limit
      ):
          self.offsets = self.offsets[: num_examples_limit + 1]
          self.buffer = self.buffer[: self.offsets[-1]]
      self.sizes = self.offsets[1:] - self.offsets[:-1]
  
imports: import os
  import shutil
  import tempfile
  from typing import Dict, NamedTuple, Optional
  import numpy
  import torch
  from fairseq import data, tokenizer
  from fvcore.common.file_io import PathManager
  from pytorch_translate import constants
  from pytorch_translate.data import dictionary
label_desc: Use image node_id 7 for calling the InMemoryIndexedDataset obj's underlying member method code with example usage: obj.load(path, num_examples_limit) without return types