parameters: (sentences, vocab=None, invalid_label=-1, invalid_key='\n', start_label=0)
return_statement: return res, vocab
docstring: Encode sentences and (optionally) build a mapping
      from string tokens to integer indices. Unknown keys
      will be added to vocabulary.
  
      Parameters
      ----------
      sentences : list of list of str
          A list of sentences to encode. Each sentence
          should be a list of string tokens.
      vocab : None or dict of str -> int
          Optional input Vocabulary
      invalid_label : int, default -1
          Index for invalid token, like <end-of-sentence>
      invalid_key : str, default '\\n'
          Key for invalid token. Use '\\n' for end
          of sentence by default.
      start_label : int
          lowest index.
  
      Returns
      -------
      result : list of list of int
          encoded sentences
      vocab : dict of str -> int
          result vocabulary
docstring_summary: Encode sentences and (optionally) build a mapping
      from string tokens to integer indices. Unknown keys
      will be added to vocabulary.
docstring_tokens: Encode sentences and ( optionally ) build a mapping from string tokens to integer indices . Unknown keys will be added to vocabulary .
function: def encode_sentences(sentences, vocab=None, invalid_label=-1, invalid_key='\n', start_label=0):
      """Encode sentences and (optionally) build a mapping
      from string tokens to integer indices. Unknown keys
      will be added to vocabulary.
  
      Parameters
      ----------
      sentences : list of list of str
          A list of sentences to encode. Each sentence
          should be a list of string tokens.
      vocab : None or dict of str -> int
          Optional input Vocabulary
      invalid_label : int, default -1
          Index for invalid token, like <end-of-sentence>
      invalid_key : str, default '\\n'
          Key for invalid token. Use '\\n' for end
          of sentence by default.
      start_label : int
          lowest index.
  
      Returns
      -------
      result : list of list of int
          encoded sentences
      vocab : dict of str -> int
          result vocabulary
      """
      idx = start_label
      if vocab is None:
          vocab = {invalid_key: invalid_label}
          new_vocab = True
      else:
          new_vocab = False
      res = []
      for sent in sentences:
          coded = []
          for word in sent:
              if word not in vocab:
                  assert new_vocab, "Unknown token %s"%word
                  if idx == invalid_label:
                      idx += 1
                  vocab[word] = idx
                  idx += 1
              coded.append(vocab[word])
          res.append(coded)
  
      return res, vocab
function_tokens: def encode_sentences ( sentences , vocab = None , invalid_label = - 1 , invalid_key = '\n' , start_label = 0 ) : idx = start_label if vocab is None : vocab = { invalid_key : invalid_label } new_vocab = True else : new_vocab = False res = [ ] for sent in sentences : coded = [ ] for word in sent : if word not in vocab : assert new_vocab , "Unknown token %s" % word if idx == invalid_label : idx += 1 vocab [ word ] = idx idx += 1 coded . append ( vocab [ word ] ) res . append ( coded ) return res , vocab