class_docstr: Indexed corpus is a mechanism for random-accessing corpora.
  
  While the standard corpus interface in gensim allows iterating over corpus,
  we'll show it with :class:`~gensim.corpora.mmcorpus.MmCorpus`.
  
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import MmCorpus
      >>> from gensim.test.utils import datapath
      >>>
      >>> corpus = MmCorpus(datapath('testcorpus.mm'))
      >>> for doc in corpus:
      ...     pass
  
  :class:`~gensim.corpora.indexedcorpus.IndexedCorpus` allows accessing the documents with index
  in :math:`{O}(1)` look-up time.
  
  .. sourcecode:: pycon
  
      >>> document_index = 3
      >>> doc = corpus[document_index]
  
  Notes
  -----
  This functionality is achieved by storing an extra file (by default named the same as the `fname.index`)
  that stores the byte offset of the beginning of each document.
docstr: Parameters
  ----------
  fname : str
      Path to corpus.
  index_fname : str, optional
      Path to index, if not provided - used `fname.index`.
code: def __init__(self, fname, index_fname=None):
      """
  
      Parameters
      ----------
      fname : str
          Path to corpus.
      index_fname : str, optional
          Path to index, if not provided - used `fname.index`.
  
      """
      try:
          if index_fname is None:
              index_fname = utils.smart_extension(fname, ".index")
          self.index = utils.unpickle(index_fname)
          # change self.index into a numpy.ndarray to support fancy indexing
          self.index = numpy.asarray(self.index)
          logger.info("loaded corpus index from %s", index_fname)
      except Exception:
          self.index = None
      self.length = None
  
file_path: gensim/gensim/corpora/indexedcorpus.py
imports: import logging
  import numpy
  from gensim import interfaces, utils
label_desc: Use image node_id 1 to create a new IndexedCorpus object from inherited base classes: interfaces with example: obj = IndexedCorpus(fname, index_fname)