class_docstr: Wrapper for a Huggingface Transformers GPT-2 model.
  
  This class loads a tokenizer and model using the Huggingface library and
  provides the LIT-required functions plus additional helper functions to
  convert and clean tokens and to compute the top_k predictions from logits.
class_docstr_tok: ["Wrapper","for","a","Huggingface","Transformers","GPT-2","model",".","This","class","loads","a","tokenizer","and","model","using","the","Huggingface","library","and","provides","the","LIT-required","functions","plus","additional","helper","functions","to","convert","and","clean","tokens","and","to","compute","the","top_k","predictions","from","logits","."]
code: def output_spec(self):
      spec = {
          # the "parent" keyword tells LIT which field in the input spec we should
          # compare this to when computing metrics.
          "pred_tokens": lit_types.TokenTopKPreds(align="tokens"),
          "tokens": lit_types.Tokens(parent="text"),  # all tokens
      }
      # Add attention and embeddings from each layer.
      for i in range(self.num_layers):
          spec[f"layer_{i+1:d}_attention"] = lit_types.AttentionHeads(
              align_in="tokens", align_out="tokens"
          )
          spec[f"layer_{i:d}_avg_embedding"] = lit_types.Embeddings()
      return spec
  
imports: import re
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.examples.models import model_utils
  from lit_nlp.lib import file_cache
  from lit_nlp.lib import utils
  import numpy
  import tensorflow
  import transformers
label_desc: Use image node_id 11 for calling the GPT2LanguageModel obj's underlying member method code with example usage: obj.output_spec() and returns: spec