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 for text segment inputs.
  
  Args:
    inputs: the model inputs, which contain any custom embeddings to scatter.
    input_embs: the default model embeddings.
  
  Returns:
    The default model embeddings with scattered custom embeddings.
docstr_tok: ["Scatters","custom","passed","embeddings","for","text","segment","inputs",".","Args",":","inputs",":","the","model","inputs",",","which","contain","any","custom","embeddings","to","scatter",".","input_embs",":","the","default","model","embeddings",".","Returns",":","The","default","model","embeddings","with","scattered","custom","embeddings","."]
code: def scatter_all_embeddings(self, inputs, input_embs):
      """Scatters custom passed embeddings for text segment inputs.
  
      Args:
        inputs: the model inputs, which contain any custom embeddings to scatter.
        input_embs: the default model embeddings.
  
      Returns:
        The default model embeddings with scattered custom embeddings.
      """
      # Gets batch indices of any word embeddings that were passed for text_a.
      passed_input_embs_a = [
          ex.get("input_embs_" + self.config.text_a_name)
          for ex in inputs
      ]
      batch_indices_a = [
          index
          for (index, emb) in enumerate(passed_input_embs_a)
          if emb is not None
      ]
  
      # If word embeddings were passed in for text_a, scatter them into the
      # embeddings, gathered from the input ids. 1 is passed in as the offset
      # for each, since text_a starts at index 1, after the [CLS] token.
      if batch_indices_a:
          input_embs = self._scatter_embs(
              passed_input_embs_a,
              input_embs,
              batch_indices_a,
              offsets=np.ones(len(batch_indices_a), dtype=np.int64),
          )
  
      if self.config.text_b_name:
          # Gets batch indices of any word embeddings that were passed for text_b.
          passed_input_embs_b = [
              ex.get("input_embs_" + self.config.text_b_name)
              for ex in inputs
          ]
          batch_indices_b = [
              index
              for (index, emb) in enumerate(passed_input_embs_b)
              if emb is not None
          ]
  
          # If word embeddings were also passed in for text_b, scatter them into the
          # embeddings gathered from the input ids. The offsets are the [lengths
          # of the corresponding text_a embeddings] + 2, since text_b starts after
          # [CLS] [text_a tokens] [SEP]. (This assumes that text_b embeddings
          # will only be passed together with text_a embeddings.)
          if batch_indices_b:
              lengths = np.array(
                  [
                      len(embed)
                      for embed in passed_input_embs_a
                      if embed is not None
                  ]
              )
              input_embs = self._scatter_embs(
                  passed_input_embs_b,
                  input_embs,
                  batch_indices_b,
                  offsets=(lengths + 2),
              )
      return input_embs
  
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 13 for calling the GlueModel obj's underlying member method code with example usage: obj.scatter_all_embeddings(inputs, input_embs) and returns: input_embs