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","."]
docstr: Get target-class scores, as a 1D tensor.
  
  Args:
    inputs: list of input examples
    scores: <tf.float32>[batch_size, num_classes], either logits or probas
  
  Returns:
    <tf.float32>[batch_size] target scores for each input
docstr_tok: ["Get","target-class","scores",",","as","a","1D","tensor",".","Args",":","inputs",":","list","of","input","examples","scores",":","<","tf.float32",">","[","batch_size",",","num_classes","]",",","either","logits","or","probas","Returns",":","<","tf.float32",">","[","batch_size","]","target","scores","for","each","input"]
code: def get_target_scores(self, inputs: Iterable[JsonDict], scores):
      """Get target-class scores, as a 1D tensor.
  
      Args:
        inputs: list of input examples
        scores: <tf.float32>[batch_size, num_classes], either logits or probas
  
      Returns:
        <tf.float32>[batch_size] target scores for each input
      """
      arg_max = tf.math.argmax(scores, axis=-1).numpy()
      grad_classes = [
          ex.get(self.config.label_name, arg_max[i])
          for (i, ex) in enumerate(inputs)
      ]
      # Convert the class names to indices if needed.
      grad_idxs = [
          self.config.labels.index(label)
          if isinstance(label, str)
          else label
          for label in grad_classes
      ]
      # list of tuples (batch idx, label idx)
      gather_indices = list(enumerate(grad_idxs))
      # <tf.float32>[batch_size]
      return tf.gather_nd(scores, gather_indices), grad_idxs
  
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 14 for calling the GlueModel obj's underlying member method code with example usage: obj.get_target_scores(inputs, scores) and returns: tf,  grad_idxs