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","."]
docstr: Subsample dataset to include only those items indexed by input
  argument indices.
docstr_tok: ["Subsample","dataset","to","include","only","those","items","indexed","by","input","argument","indices","."]
code: def subsample(self, indices):
      """
      Subsample dataset to include only those items indexed by input
      argument indices.
      """
      array_list = []
      offsets = [0]
      sizes = []
      for i in indices:
          array_list.append(self[i])
          offsets.append(offsets[-1] + len(array_list[-1]))
          sizes.append(len(array_list[-1]))
      self.buffer = np.concatenate(array_list)
      self.offsets = np.array(offsets, dtype=np.int32)
      self.sizes = np.array(sizes, dtype=np.int32)
  
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 12 for calling the InMemoryIndexedDataset obj's underlying member method code with example usage: obj.subsample(indices) without return types