class_docstr: GLUE benchmark model, using Keras/TF2 and Huggingface Transformers.
  
  This is a general-purpose classification or regression model. It works for
  one- or two-segment input, and predicts either a multiclass label or
  a regression score. See GlueModelConfig for available options.
  
  This implements the LIT API for inference (e.g. input_spec(), output_spec(),
  and predict()), but also provides a train() method to run fine-tuning.
  
  This is a full-featured implementation, which includes embeddings, attention,
  gradients, as well as support for the different input and output types above.
  For a more minimal example, see ../simple_tf2_demo.py.
class_docstr_tok: ["GLUE","benchmark","model",",","using","Keras\/TF2","and","Huggingface","Transformers",".","This","is","a","general-purpose","classification","or","regression","model",".","It","works","for","one-","or","two-segment","input",",","and","predicts","either","a","multiclass","label","or","a","regression","score",".","See","GlueModelConfig","for","available","options",".","This","implements","the","LIT","API","for","inference","(","e.g",".","input_spec","(",")",",","output_spec","(",")",",","and","predict","(",")",")",",","but","also","provides","a","train","(",")","method","to","run","fine-tuning",".","This","is","a","full-featured","implementation",",","which","includes","embeddings",",","attention",",","gradients",",","as","well","as","support","for","the","different","input","and","output","types","above",".","For","a","more","minimal","example",",","see","..","\/simple_tf2_demo.py","."]
code: def output_spec(self) -> Spec:
      ret = {"tokens": lit_types.Tokens()}
      ret["tokens_" + self.config.text_a_name] = lit_types.Tokens(
          parent=self.config.text_a_name
      )
      if self.config.text_b_name:
          ret["tokens_" + self.config.text_b_name] = lit_types.Tokens(
              parent=self.config.text_b_name
          )
      if self.is_regression:
          ret["score"] = lit_types.RegressionScore(
              parent=self.config.label_name
          )
      else:
          ret["probas"] = lit_types.MulticlassPreds(
              parent=self.config.label_name,
              vocab=self.config.labels,
              null_idx=self.config.null_label_idx,
          )
  
      if self.config.output_embeddings:
          ret["cls_emb"] = lit_types.Embeddings()
          # Average embeddings, one per layer including embeddings.
          for i in range(1 + self.model.config.num_hidden_layers):
              ret[f"layer_{i}/avg_emb"] = lit_types.Embeddings()
  
          # The input_embs_ fields are used for Integrated Gradients.
          ret[
              "input_embs_" + self.config.text_a_name
          ] = lit_types.TokenEmbeddings(
              align="tokens_" + self.config.text_a_name
          )
          if self.config.text_b_name:
              text_b_embs = "input_embs_" + self.config.text_b_name
              ret[text_b_embs] = lit_types.TokenEmbeddings(
                  align="tokens_" + self.config.text_b_name
              )
  
      # Gradients, if requested.
      if self.config.compute_grads:
          ret["cls_grad"] = lit_types.Gradients(
              align=("score" if self.is_regression else "probas"),
              grad_for="cls_emb",
              grad_target_field_key=self.config.label_name,
          )
          if not self.is_regression:
              ret[self.config.label_name] = lit_types.CategoryLabel(
                  required=False, vocab=self.config.labels
              )
          if self.config.output_embeddings:
              text_a_token_grads = (
                  "token_grad_" + self.config.text_a_name
              )
              ret[text_a_token_grads] = lit_types.TokenGradients(
                  align="tokens_" + self.config.text_a_name,
                  grad_for="input_embs_" + self.config.text_a_name,
                  grad_target_field_key=self.config.label_name,
              )
              if self.config.text_b_name:
                  text_b_token_grads = (
                      "token_grad_" + self.config.text_b_name
                  )
                  ret[text_b_token_grads] = lit_types.TokenGradients(
                      align="tokens_" + self.config.text_b_name,
                      grad_for="input_embs_" + self.config.text_b_name,
                      grad_target_field_key=self.config.label_name,
                  )
  
      if self.config.output_attention:
          # Attention heads, one field for each layer.
          for i in range(self.model.config.num_hidden_layers):
              ret[f"layer_{i+1}/attention"] = lit_types.AttentionHeads(
                  align_in="tokens", align_out="tokens"
              )
      return ret
  
imports: import os
  from collections.abc import Iterable, Sequence
  import re
  import threading
  from typing import Any, Optional
  import attr
  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 19 for calling the GlueModel obj's underlying member method code with example usage: obj.output_spec() and returns: ret