class_docstr: A `TokenIndexer` determines how string tokens get represented as arrays of indices in a model.
  This class both converts strings into numerical values, with the help of a
  :class:`~allennlp.data.vocabulary.Vocabulary`, and it produces actual arrays.
  
  Tokens can be represented as single IDs (e.g., the word "cat" gets represented by the number
  34), or as lists of character IDs (e.g., "cat" gets represented by the numbers [23, 10, 18]),
  or in some other way that you can come up with (e.g., if you have some structured input you
  want to represent in a special way in your data arrays, you can do that here).
  
  # Parameters
  
  token_min_padding_length : `int`, optional (default=`0`)
      The minimum padding length required for the :class:`TokenIndexer`. For example,
      the minimum padding length of :class:`SingleIdTokenIndexer` is the largest size of
      filter when using :class:`CnnEncoder`.
      Note that if you set this for one TokenIndexer, you likely have to set it for all
      :class:`TokenIndexer` for the same field, otherwise you'll get mismatched tensor sizes.
class_docstr_tok: ["A","`","TokenIndexer","`","determines","how","string","tokens","get","represented","as","arrays","of","indices","in","a","model",".","This","class","both","converts","strings","into","numerical","values",",","with","the","help","of","a",":","class",":","`","~allennlp.data.vocabulary.Vocabulary","`",",","and","it","produces","actual","arrays",".","Tokens","can","be","represented","as","single","IDs","(","e.g.",",","the","word","``","cat","''","gets","represented","by","the","number","34",")",",","or","as","lists","of","character","IDs","(","e.g.",",","``","cat","''","gets","represented","by","the","numbers","[","23",",","10",",","18","]",")",",","or","in","some","other","way","that","you","can","come","up","with","(","e.g.",",","if","you","have","some","structured","input","you","want","to","represent","in","a","special","way","in","your","data","arrays",",","you","can","do","that","here",")",".","#","Parameters","token_min_padding_length",":","`","int","`",",","optional","(","default=","`","0","`",")","The","minimum","padding","length","required","for","the",":","class",":","`","TokenIndexer","`",".","For","example",",","the","minimum","padding","length","of",":","class",":","`","SingleIdTokenIndexer","`","is","the","largest","size","of","filter","when","using",":","class",":","`","CnnEncoder","`",".","Note","that","if","you","set","this","for","one","TokenIndexer",",","you","likely","have","to","set","it","for","all",":","class",":","`","TokenIndexer","`","for","the","same","field",",","otherwise","you","'ll","get","mismatched","tensor","sizes","."]
docstr: This method pads a list of tokens given the input padding lengths (which could actually
  truncate things, depending on settings) and returns that padded list of input tokens as a
  `Dict[str, torch.Tensor]`.  This is a dictionary because there should be one key per
  argument that the `TokenEmbedder` corresponding to this class expects in its `forward()`
  method (where the argument name in the `TokenEmbedder` needs to make the key in this
  dictionary).
  
  The base class implements the case when all you want to do is create a padded `LongTensor`
  for every list in the `tokens` dictionary.  If your `TokenIndexer` needs more complex
  logic than that, you need to override this method.
docstr_tok: ["This","method","pads","a","list","of","tokens","given","the","input","padding","lengths","(","which","could","actually","truncate","things",",","depending","on","settings",")","and","returns","that","padded","list","of","input","tokens","as","a","`","Dict","[","str",",","torch.Tensor","]","`",".","This","is","a","dictionary","because","there","should","be","one","key","per","argument","that","the","`","TokenEmbedder","`","corresponding","to","this","class","expects","in","its","`","forward","(",")","`","method","(","where","the","argument","name","in","the","`","TokenEmbedder","`","needs","to","make","the","key","in","this","dictionary",")",".","The","base","class","implements","the","case","when","all","you","want","to","do","is","create","a","padded","`","LongTensor","`","for","every","list","in","the","`","tokens","`","dictionary",".","If","your","`","TokenIndexer","`","needs","more","complex","logic","than","that",",","you","need","to","override","this","method","."]
code: def as_padded_tensor_dict(
      self, tokens: IndexedTokenList, padding_lengths: Dict[str, int]
  ) -> Dict[str, torch.Tensor]:
      """
      This method pads a list of tokens given the input padding lengths (which could actually
      truncate things, depending on settings) and returns that padded list of input tokens as a
      `Dict[str, torch.Tensor]`.  This is a dictionary because there should be one key per
      argument that the `TokenEmbedder` corresponding to this class expects in its `forward()`
      method (where the argument name in the `TokenEmbedder` needs to make the key in this
      dictionary).
  
      The base class implements the case when all you want to do is create a padded `LongTensor`
      for every list in the `tokens` dictionary.  If your `TokenIndexer` needs more complex
      logic than that, you need to override this method.
      """
      tensor_dict = {}
      for key, val in tokens.items():
          if val and isinstance(val[0], bool):
              tensor = torch.BoolTensor(
                  pad_sequence_to_length(
                      val,
                      padding_lengths[key],
                      default_value=lambda: False,
                  )
              )
          else:
              tensor = torch.LongTensor(
                  pad_sequence_to_length(val, padding_lengths[key])
              )
          tensor_dict[key] = tensor
      return tensor_dict
  
file_path: allennlp/allennlp/data/token_indexers/token_indexer.py
imports: from typing import Any, Dict, List
  import torch
  from allennlp.common import Registrable
  from allennlp.common.util import pad_sequence_to_length
  from allennlp.data.tokenizers import Token
  from allennlp.data.vocabulary import Vocabulary
label_desc: Use image node_id 7 for calling the TokenIndexer obj's underlying member method code with example usage: obj.as_padded_tensor_dict(tokens, padding_lengths) and returns: tensor_dict