class_docstr: T5 using HuggingFace Transformers and Keras.
  
  This version supports embeddings, attention, and force-decoding of the target
  text, as well as more options to control decoding (such as beam search).
docstr: Run model on a single batch.
docstr_tok: ["Run","model","on","a","single","batch","."]
code: def predict_minibatch(self, inputs: list[JsonDict]) -> list[JsonDict]:
      """Run model on a single batch."""
      # Text as sequence of sentencepiece ID"s.
      encoded_inputs = self._encode_texts(
          [ex["input_text"] for ex in inputs]
      )
      encoded_targets = self._encode_texts(
          [ex.get("target_text", "") for ex in inputs]
      )
  
      ##
      # Force-decode on target text, and also get encoder embs and attention.
      batched_outputs = self._force_decode(
          encoded_inputs, encoded_targets
      )
      # Get the conditional generation from the model.
      # Workaround for output_hidden not being compatible with generate.
      # See https://github.com/huggingface/transformers/issues/8361
      self.model.config.output_hidden_states = False
      generated_ids = self.model.generate(
          encoded_inputs.input_ids,
          num_beams=self.config.beam_size,
          attention_mask=encoded_inputs.attention_mask,
          max_length=self.config.max_gen_length,
          num_return_sequences=self.config.num_to_generate,
      )
      # [batch_size*num_return_sequences, num_steps]
      # -> [batch_size, num_return_sequences, num_steps]
      batched_outputs["generated_ids"] = tf.reshape(
          generated_ids,
          [-1, self.config.num_to_generate, generated_ids.shape[-1]],
      )
      self.model.config.output_hidden_states = True
  
      # Convert to numpy for post-processing.
      detached_outputs = {
          k: v.numpy() for k, v in batched_outputs.items()
      }
      # Split up batched outputs, then post-process each example.
      unbatched_outputs = utils.unbatch_preds(detached_outputs)
      return list(map(self._postprocess, unbatched_outputs))
  
imports: import re
  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 tensorflow
  import tensorflow_text
  import transformers
  from rouge_score import rouge_scorer
label_desc: Use image node_id 7 for calling the T5HFModel obj's underlying member method code with example usage: obj.predict_minibatch(inputs) and returns: list