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: Scatters custom passed embeddings into the default model embeddings.
  
  Args:
    passed_input_embs: <tf.float32>[num_scatter_tokens], the custom passed
      embeddings to be scattered into the default model embeddings.
    input_embs: the default model embeddings.
    batch_indices: the indices of the embeddings to replace in the format
      (batch_index, sequence_index).
    offsets: the offset from which to scatter the custom embedding (number of
      tokens from the start of the sequence).
  
  Returns:
    The default model embeddings with scattered custom embeddings.
docstr_tok: ["Scatters","custom","passed","embeddings","into","the","default","model","embeddings",".","Args",":","passed_input_embs",":","<","tf.float32",">","[","num_scatter_tokens","]",",","the","custom","passed","embeddings","to","be","scattered","into","the","default","model","embeddings",".","input_embs",":","the","default","model","embeddings",".","batch_indices",":","the","indices","of","the","embeddings","to","replace","in","the","format","(","batch_index",",","sequence_index",")",".","offsets",":","the","offset","from","which","to","scatter","the","custom","embedding","(","number","of","tokens","from","the","start","of","the","sequence",")",".","Returns",":","The","default","model","embeddings","with","scattered","custom","embeddings","."]
code: def _scatter_embs(
      self, passed_input_embs, input_embs, batch_indices, offsets
  ):
      """Scatters custom passed embeddings into the default model embeddings.
  
      Args:
        passed_input_embs: <tf.float32>[num_scatter_tokens], the custom passed
          embeddings to be scattered into the default model embeddings.
        input_embs: the default model embeddings.
        batch_indices: the indices of the embeddings to replace in the format
          (batch_index, sequence_index).
        offsets: the offset from which to scatter the custom embedding (number of
          tokens from the start of the sequence).
  
      Returns:
        The default model embeddings with scattered custom embeddings.
      """
  
      # <float32>[scatter_batch_size, num_tokens, emb_size]
      filtered_embs = [
          emb for emb in passed_input_embs if emb is not None
      ]
  
      # Prepares update values that should be scattered in, i.e. one for each
      # of the (scatter_batch_size * num_tokens) word embeddings.
      # <np.float32>[scatter_batch_size * num_tokens, emb_size]
      updates = np.concatenate(filtered_embs)
  
      # Prepares indices in format (batch_index, sequence_index) for all
      # values that should be scattered in, i.e. one for each of the
      # (scatter_batch_size * num_tokens) word embeddings.
      scatter_indices = []
      for batch_index, sentence_embs, offset in zip(
          batch_indices, filtered_embs, offsets
      ):
          for token_index, _ in enumerate(sentence_embs):
              scatter_indices.append(
                  [batch_index, token_index + offset]
              )
  
      # Scatters passed word embeddings into embeddings gathered from tokens.
      # <tf.float32>[batch_size, num_tokens + num_special_tokens, emb_size]
      return tf.tensor_scatter_nd_update(
          input_embs, scatter_indices, updates
      )
  
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 12 for calling the GlueModel obj's underlying member method code with example usage: obj._scatter_embs(passed_input_embs, input_embs, batch_indices, offsets) and returns: tf