def batch_namedtuples(namedtuples):
  """Combines a batch of namedtuples into a single namedtuple of the same type.

  Args:
    namedtuples: a list of namedtuples, all of the same type.

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

  nt_type = type(namedtuples[0])
  dicts = [nt._asdict() for nt in namedtuples]
  batched_dict = batch_feature_dicts(dicts)
  return nt_type(**batched_dict)
Combines a batch of namedtuples into a single namedtuple of the same type.

  Args:
    namedtuples: a list of namedtuples, all of the same type.

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