def _IsNamedTuple(x):
  """Returns whether an object is an instance of a collections.namedtuple.

  Examples::

    _IsNamedTuple((42, 'hi')) ==> False
    Foo = collections.namedtuple('Foo', ['a', 'b'])
    _IsNamedTuple(Foo(a=42, b='hi')) ==> True

  Args:
    x: The object to check.
  """
  return isinstance(x, tuple) and hasattr(x, '_fields')