code: def scatter_feats(output_shape, sequence_feats, scatter_vals):
      """
      The inverse of gather_col_vals - maps from columnwise inputs back to the original layout.
      When features are represented in multiple places mean reduction is used.
      0 is used as the default where no tokens in the input map to tokens in the output.
  
      Args:
          output_shape: Expected shape of the output.
          sequence_feats: features from either the row or col model.
          scatter_vals: the scatter vals output from gather_tables - the indices of the original positions of each token.
  
      Returns:
          The reformatted features.
      """
      input_tensor = tf.zeros(shape=output_shape, dtype=tf.float32)
      mask = tf.math.less(
          scatter_vals[:, :, 0], output_shape[1]
      )  # Special tokens were placed after the length of the shape.
      feats = tf.boolean_mask(sequence_feats, mask)
      scatter_idxs = tf.boolean_mask(scatter_vals, mask)
      # Averages any cases where tokens are in multiple cells - for example when cells span multiple rows / cols.
      divide_by = tf.tensor_scatter_nd_add(
          input_tensor, scatter_idxs, tf.ones_like(feats)
      )
      return tf.math.divide_no_nan(
          tf.tensor_scatter_nd_add(input_tensor, scatter_idxs, feats),
          divide_by,
      )
  
file_path: finetune/finetune/base_models/bert/table_utils.py
imports: import tensorflow
  from finetune.base_models.bert.modeling import gelu
label_desc: Use image node_id 8 for calling a global function with example usage: scatter_feats(output_shape, sequence_feats, scatter_vals) and returns: tf