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: Get the index length.
  
  Notes
  -----
  If the corpus is not indexed, also count corpus length and cache this value.
  
  Returns
  -------
  int
      Length of index.
code: def __len__(self):
      """Get the index length.
  
      Notes
      -----
      If the corpus is not indexed, also count corpus length and cache this value.
  
      Returns
      -------
      int
          Length of index.
  
      """
      if self.index is not None:
          return len(self.index)
      if self.length is None:
          logger.info("caching corpus length")
          self.length = sum(1 for _ in self)
      return self.length
  
file_path: gensim/gensim/corpora/indexedcorpus.py
imports: import logging
  import numpy
  from gensim import interfaces, utils
label_desc: Use image node_id 3 for calling the IndexedCorpus obj's underlying member method code with example usage: obj.__len__() and returns: self, len