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 create_from_file(
      path, is_npz=True, num_examples_limit: Optional[int] = None
  ):
      if is_npz:
          # npz format
          result = InMemoryIndexedDataset()
          result.load(path, num_examples_limit=num_examples_limit)
          return result
      else:
          # idx, bin format
          if path.startswith("manifold://"):
              tempdir = tempfile.mkdtemp()
              basename = os.path.basename(path)
              prefix = os.path.join(tempdir, basename)
              for suffix in ("bin", "idx"):
                  remote_path = f"{path}.{suffix}"
                  local_path = PathManager.get_local_path(remote_path)
                  shutil.copy(local_path, f"{prefix}.{suffix}")
              path = prefix
          return data.indexed_dataset.MMapIndexedDataset(path)
  
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 11 for calling the InMemoryIndexedDataset obj's underlying member method code with example usage: obj.create_from_file(path, is_npz, num_examples_limit) and returns: result, data