class_docstr: Dictionary encapsulates the mapping between normalized words and their integer ids.
  
  Notable instance attributes:
  
  Attributes
  ----------
  token2id : dict of (str, int)
      token -> token_id. I.e. the reverse mapping to `self[token_id]`.
  cfs : dict of (int, int)
      Collection frequencies: token_id -> how many instances of this token are contained in the documents.
  dfs : dict of (int, int)
      Document frequencies: token_id -> how many documents contain this token.
  num_docs : int
      Number of documents processed.
  num_pos : int
      Total number of corpus positions (number of processed words).
  num_nnz : int
      Total number of non-zeroes in the BOW matrix (sum of the number of unique
      words per document over the entire corpus).
class_docstr_tok: ["Dictionary","encapsulates","the","mapping","between","normalized","words","and","their","integer","ids",".","Notable","instance","attributes",":","Attributes","--","--","--","--","--","token2id",":","dict","of","(","str",",","int",")","token","-",">","token_id",".","I.e",".","the","reverse","mapping","to","`","self","[","token_id","]","`",".","cfs",":","dict","of","(","int",",","int",")","Collection","frequencies",":","token_id","-",">","how","many","instances","of","this","token","are","contained","in","the","documents",".","dfs",":","dict","of","(","int",",","int",")","Document","frequencies",":","token_id","-",">","how","many","documents","contain","this","token",".","num_docs",":","int","Number","of","documents","processed",".","num_pos",":","int","Total","number","of","corpus","positions","(","number","of","processed","words",")",".","num_nnz",":","int","Total","number","of","non-zeroes","in","the","BOW","matrix","(","sum","of","the","number","of","unique","words","per","document","over","the","entire","corpus",")","."]
docstr: Convert `document` (a list of words) into a list of indexes = list of `token_id`.
  Replace all unknown words i.e, words not in the dictionary with the index as set via `unknown_word_index`.
  
  Parameters
  ----------
  document : list of str
      Input document
  unknown_word_index : int, optional
      Index to use for words not in the dictionary.
  
  Returns
  -------
  list of int
      Token ids for tokens in `document`, in the same order.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import Dictionary
      >>>
      >>> corpus = [["a", "a", "b"], ["a", "c"]]
      >>> dct = Dictionary(corpus)
      >>> dct.doc2idx(["a", "a", "c", "not_in_dictionary", "c"])
      [0, 0, 2, -1, 2]
docstr_tok: ["Convert","`","document","`","(","a","list","of","words",")","into","a","list","of","indexes","=","list","of","`","token_id","`",".","Replace","all","unknown","words","i.e",",","words","not","in","the","dictionary","with","the","index","as","set","via","`","unknown_word_index","`",".","Parameters","--","--","--","--","--","document",":","list","of","str","Input","document","unknown_word_index",":","int",",","optional","Index","to","use","for","words","not","in","the","dictionary",".","Returns","--","--","--","-","list","of","int","Token","ids","for","tokens","in","`","document","`",",","in","the","same","order",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">",">",">",">","corpus","=","[","[","``","a","''",",","``","a","''",",","``","b","''","]",",","[","``","a","''",",","``","c","''","]","]",">",">",">","dct","=","Dictionary","(","corpus",")",">",">",">","dct.doc2idx","(","[","``","a","''",",","``","a","''",",","``","c","''",",","``","not_in_dictionary","''",",","``","c","''","]",")","[","0",",","0",",","2",",","-1",",","2","]"]
code: def doc2idx(self, document, unknown_word_index=-1):
      """Convert `document` (a list of words) into a list of indexes = list of `token_id`.
      Replace all unknown words i.e, words not in the dictionary with the index as set via `unknown_word_index`.
  
      Parameters
      ----------
      document : list of str
          Input document
      unknown_word_index : int, optional
          Index to use for words not in the dictionary.
  
      Returns
      -------
      list of int
          Token ids for tokens in `document`, in the same order.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora import Dictionary
          >>>
          >>> corpus = [["a", "a", "b"], ["a", "c"]]
          >>> dct = Dictionary(corpus)
          >>> dct.doc2idx(["a", "a", "c", "not_in_dictionary", "c"])
          [0, 0, 2, -1, 2]
  
      """
      if isinstance(document, str):
          raise TypeError(
              "doc2idx expects an array of unicode tokens on input, not a single string"
          )
  
      document = [
          word if isinstance(word, str) else str(word, "utf-8")
          for word in document
      ]
      return [
          self.token2id.get(word, unknown_word_index)
          for word in document
      ]
  
imports: from collections import defaultdict
  from collections.abc import Mapping
  import logging
  import itertools
  from typing import Optional, List, Tuple
  from gensim import utils
label_desc: Use image node_id 12 for calling the Dictionary obj's underlying member method code with example usage: obj.doc2idx(document, unknown_word_index) and returns: unknown