def merged_namedtuple(cls, source, **kwargs):
  """Fill a namedtuple with elements from a different namedtuple and extra kwargs.

  Args:
    cls: namedtuple class Type that will be created.
    source: namedtuple Instance whose members are used for the new instance of
      cls.
    **kwargs: Extra arguments used to fill cls.

  Returns:
    A namedtuple of type cls
  """
  f = {}
  for field in source._fields:
    f[field] = getattr(source, field)
  for field in kwargs:
    f[field] = kwargs[field]
  return cls(**f)