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 _preprocess(
      self, inputs: Iterable[JsonDict]
  ) -> dict[str, tf.Tensor]:
      # Use pretokenized input if available.
      tokens_a = [
          self._get_tokens(ex, self.config.text_a_name) for ex in inputs
      ]
      tokens_b = None
      if self.config.text_b_name:
          tokens_b = [
              self._get_tokens(ex, self.config.text_b_name)
              for ex in inputs
          ]
      # Use custom tokenizer call to make sure we don't mangle pre-split
      # wordpieces in pretokenized input.
      encoded_input = model_utils.batch_encode_pretokenized(
          self.tokenizer,
          tokens_a,
          tokens_b,
          max_length=self.config.max_seq_length,
      )
      return encoded_input
  
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 6 for calling the GlueModel obj's underlying member method code with example usage: obj._preprocess(inputs) and returns: encoded_input