def batch_feature_dicts(feature_dicts):
  """Combines a batch of feature dicts into a single dict.

  Args:
    feature_dicts: a list of dicts, each mapping strings to Numpy arrays or TF
      Tensors. They must all share the same keys.

  Returns:
    a single dict, where each value is the result of stacking all values from
    the original inputs along the the first dimension.
  """
  if not feature_dicts:
    return feature_dicts

  batched = {}
  feature_names = feature_dicts[0].keys()
  for feature_name in feature_names:
    batched[feature_name] = tf.stack([d[feature_name] for d in feature_dicts])
  return batched
Combines a batch of feature dicts into a single dict.

  Args:
    feature_dicts: a list of dicts, each mapping strings to Numpy arrays or TF
      Tensors. They must all share the same keys.

  Returns:
    a single dict, where each value is the result of stacking all values from
    the original inputs along the the first dimension.
  
language/realm/featurization.py