def is_namedtuple(cls: type) -> bool:
  """Determines if a class is built from typing.NamedTuple."""
  return (
      isinstance(cls, type) and issubclass(cls, tuple) and
      hasattr(cls, '_fields') and hasattr(cls, '__annotations__'))