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 document by `docno` index.
  
  Parameters
  ----------
  docno : {int, iterable of int}
      Document number or iterable of numbers (like a list of str).
  
  Returns
  -------
  list of (int, float)
      If `docno` is int - return document in BoW format.
  
  :class:`~gensim.utils.SlicedCorpus`
      If `docno` is iterable of int - return several documents in BoW format
      wrapped to :class:`~gensim.utils.SlicedCorpus`.
  
  Raises
  ------
  RuntimeError
      If index isn't exist.
code: def __getitem__(self, docno):
      """Get document by `docno` index.
  
      Parameters
      ----------
      docno : {int, iterable of int}
          Document number or iterable of numbers (like a list of str).
  
      Returns
      -------
      list of (int, float)
          If `docno` is int - return document in BoW format.
  
      :class:`~gensim.utils.SlicedCorpus`
          If `docno` is iterable of int - return several documents in BoW format
          wrapped to :class:`~gensim.utils.SlicedCorpus`.
  
      Raises
      ------
      RuntimeError
          If index isn't exist.
  
      """
      if self.index is None:
          raise RuntimeError(
              "Cannot call corpus[docid] without an index"
          )
      if isinstance(docno, (slice, list, numpy.ndarray)):
          return utils.SlicedCorpus(self, docno)
      elif isinstance(
          docno,
          (
              int,
              numpy.integer,
          ),
      ):
          return self.docbyoffset(self.index[docno])
          # TODO: no `docbyoffset` method, should be defined in this class
      else:
          raise ValueError(
              "Unrecognised value for docno, use either a single integer, a slice or a numpy.ndarray"
          )
  
file_path: gensim/gensim/corpora/indexedcorpus.py
imports: import logging
  import numpy
  from gensim import interfaces, utils
label_desc: Use image node_id 4 for calling the IndexedCorpus obj's underlying member method code with example usage: obj.__getitem__(docno) and returns: utils, self