def unwrap_tf_decorator(py_object):
  """Unwraps any TF-Decorator style decoratotrs from the object.

  See `tensorflow.python.util.tf_decorator`.

  Args:
    py_object: A python object.

  Returns:
    The unwraped_object.
  """

  while True:
    decorator = getattr(py_object, '_tf_decorator', None)
    if decorator is None:
      break
    unwrapped_py_obj = getattr(decorator, 'decorated_target', None)
    if unwrapped_py_obj is None:
      break
    py_object = unwrapped_py_obj

  return py_object