class_docstr: A ``KnowledgeGraphField`` represents a ``KnowledgeGraph`` as a ``Field`` that can be used in a
  ``Model``.  For each entity in the graph, we output two things: a text representation of the
  entity, handled identically to a ``TextField``, and a list of linking features for each token
  in some input utterance.
  
  The output of this field is a dictionary::
  
      {
        "text": Dict[str, torch.Tensor],  # each tensor has shape (batch_size, num_entities, num_entity_tokens)
        "linking": torch.Tensor  # shape (batch_size, num_entities, num_utterance_tokens, num_features)
      }
  
  The ``text`` component of this dictionary is suitable to be passed into a
  ``TextFieldEmbedder`` (which handles the additional ``num_entities`` dimension without any
  issues).  The ``linking`` component of the dictionary can be used however you want to decide
  which tokens in the utterance correspond to which entities in the knowledge graph.
  
  In order to create the ``text`` component, we use the same dictionary of ``TokenIndexers``
  that's used in a ``TextField`` (as we're just representing the text corresponding to each
  entity).  For the ``linking`` component, we use a set of hard-coded feature extractors that
  operate between the text corresponding to each entity and each token in the utterance.
  
  Parameters
  ----------
  knowledge_graph : ``KnowledgeGraph``
      The knowledge graph that this field stores.
  utterance_tokens : ``List[Token]``
      The tokens in some utterance that is paired with the ``KnowledgeGraph``.  We compute a set
      of features for linking tokens in the utterance to entities in the graph.
  tokenizer : ``Tokenizer``
      We'll use this ``Tokenizer`` to tokenize the text representation of each entity.
  token_indexers : ``Dict[str, TokenIndexer]``
      Token indexers that convert entities into arrays, similar to how text tokens are treated in
      a ``TextField``.  These might operate on the name of the entity itself, its type, its
      neighbors in the graph, etc.
  feature_extractors : ``List[str]``, optional
      Names of feature extractors to use for computing linking features.  These must be
      attributes of this object, without the first underscore.  The feature extraction functions
      are listed as the last methods in this class.  For example, to use
      :func:`_exact_token_match`, you would pass the string ``exact_token_match``.  We will add
      an underscore and look for a function matching that name.  If this list is omitted, we will
      use all available feature functions.
  entity_tokens : ``List[List[Token]]``, optional
      If you have pre-computed the tokenization of the table text, you can pass it in here.  The
      must be a list of the tokens in the entity text, for each entity in the knowledge graph, in
      the same order in which the knowledge graph returns entities.
  linking_features : ``List[List[List[float]]]``, optional
      If you have pre-computed the linking features between the utterance and the table text, you
      can pass it in here.
  include_in_vocab : ``bool``, optional (default=True)
      If this is ``False``, we will skip the ``count_vocab_items`` logic, leaving out all table
      entity text from the vocabulary computation.  You might want to do this if you have a lot
      of rare entities in your tables, and you see the same table in multiple training instances,
      so your vocabulary counts get skewed and include too many rare entities.
  max_table_tokens : ``int``, optional
      If given, we will only keep this number of total table tokens.  This bounds the memory
      usage of the table representations, truncating cells with really long text.  We specify a
      total number of tokens, not a max cell text length, because the number of table entities
      varies.
class_docstr_tok: ["A","``","KnowledgeGraphField","``","represents","a","``","KnowledgeGraph","``","as","a","``","Field","``","that","can","be","used","in","a","``","Model","``",".","For","each","entity","in","the","graph",",","we","output","two","things",":","a","text","representation","of","the","entity",",","handled","identically","to","a","``","TextField","``",",","and","a","list","of","linking","features","for","each","token","in","some","input","utterance",".","The","output","of","this","field","is","a","dictionary",":",":","{","``","text","''",":","Dict","[","str",",","torch.Tensor","]",",","#","each","tensor","has","shape","(","batch_size",",","num_entities",",","num_entity_tokens",")","``","linking","''",":","torch.Tensor","#","shape","(","batch_size",",","num_entities",",","num_utterance_tokens",",","num_features",")","}","The","``","text","``","component","of","this","dictionary","is","suitable","to","be","passed","into","a","``","TextFieldEmbedder","``","(","which","handles","the","additional","``","num_entities","``","dimension","without","any","issues",")",".","The","``","linking","``","component","of","the","dictionary","can","be","used","however","you","want","to","decide","which","tokens","in","the","utterance","correspond","to","which","entities","in","the","knowledge","graph",".","In","order","to","create","the","``","text","``","component",",","we","use","the","same","dictionary","of","``","TokenIndexers","``","that","'s","used","in","a","``","TextField","``","(","as","we","'re","just","representing","the","text","corresponding","to","each","entity",")",".","For","the","``","linking","``","component",",","we","use","a","set","of","hard-coded","feature","extractors","that","operate","between","the","text","corresponding","to","each","entity","and","each","token","in","the","utterance",".","Parameters","--","--","--","--","--","knowledge_graph",":","``","KnowledgeGraph","``","The","knowledge","graph","that","this","field","stores",".","utterance_tokens",":","``","List","[","Token","]","``","The","tokens","in","some","utterance","that","is","paired","with","the","``","KnowledgeGraph","``",".","We","compute","a","set","of","features","for","linking","tokens","in","the","utterance","to","entities","in","the","graph",".","tokenizer",":","``","Tokenizer","``","We","'ll","use","this","``","Tokenizer","``","to","tokenize","the","text","representation","of","each","entity",".","token_indexers",":","``","Dict","[","str",",","TokenIndexer","]","``","Token","indexers","that","convert","entities","into","arrays",",","similar","to","how","text","tokens","are","treated","in","a","``","TextField","``",".","These","might","operate","on","the","name","of","the","entity","itself",",","its","type",",","its","neighbors","in","the","graph",",","etc",".","feature_extractors",":","``","List","[","str","]","``",",","optional","Names","of","feature","extractors","to","use","for","computing","linking","features",".","These","must","be","attributes","of","this","object",",","without","the","first","underscore",".","The","feature","extraction","functions","are","listed","as","the","last","methods","in","this","class",".","For","example",",","to","use",":","func",":","`","_exact_token_match","`",",","you","would","pass","the","string","``","exact_token_match","``",".","We","will","add","an","underscore","and","look","for","a","function","matching","that","name",".","If","this","list","is","omitted",",","we","will","use","all","available","feature","functions",".","entity_tokens",":","``","List","[","List","[","Token","]","]","``",",","optional","If","you","have","pre-computed","the","tokenization","of","the","table","text",",","you","can","pass","it","in","here",".","The","must","be","a","list","of","the","tokens","in","the","entity","text",",","for","each","entity","in","the","knowledge","graph",",","in","the","same","order","in","which","the","knowledge","graph","returns","entities",".","linking_features",":","``","List","[","List","[","List","[","float","]","]","]","``",",","optional","If","you","have","pre-computed","the","linking","features","between","the","utterance","and","the","table","text",",","you","can","pass","it","in","here",".","include_in_vocab",":","``","bool","``",",","optional","(","default=True",")","If","this","is","``","False","``",",","we","will","skip","the","``","count_vocab_items","``","logic",",","leaving","out","all","table","entity","text","from","the","vocabulary","computation",".","You","might","want","to","do","this","if","you","have","a","lot","of","rare","entities","in","your","tables",",","and","you","see","the","same","table","in","multiple","training","instances",",","so","your","vocabulary","counts","get","skewed","and","include","too","many","rare","entities",".","max_table_tokens",":","``","int","``",",","optional","If","given",",","we","will","only","keep","this","number","of","total","table","tokens",".","This","bounds","the","memory","usage","of","the","table","representations",",","truncating","cells","with","really","long","text",".","We","specify","a","total","number","of","tokens",",","not","a","max","cell","text","length",",","because","the","number","of","table","entities","varies","."]
code: def _lemma_match(
      self, entity, entity_text, token, token_index, tokens
  ):
      if len(entity_text) != 1:
          return 0.0
      return self._contains_lemma_match(
          entity, entity_text, token, token_index, tokens
      )
  
imports: from __future__ import division
  from __future__ import absolute_import
  from collections import defaultdict
  import editdistance
  import torch
  from allennlp.common import util
  from allennlp.common.checks import ConfigurationError
  from allennlp.data.fields.field import Field
  from allennlp.data.token_indexers.token_indexer import TokenIndexer
  from allennlp.data.tokenizers.token import Token
  from allennlp.data.tokenizers.tokenizer import Tokenizer
  from allennlp.data.vocabulary import Vocabulary
  from allennlp.nn import util
  from allennlp.semparse.contexts.knowledge_graph import KnowledgeGraph
label_desc: Use image node_id 12 for calling the KnowledgeGraphField obj's underlying member method code with example usage: obj._lemma_match(entity, entity_text, token, token_index, tokens) and returns: self, int