parameters: (test, body, get_state, set_state, opts)
docstring: Overload of while_stmt that executes a Python while loop.
docstring_summary: Overload of while_stmt that executes a Python while loop.
docstring_tokens: Overload of while_stmt that executes a Python while loop .
function: def _py_while_stmt(test, body, get_state, set_state, opts):
    """Overload of while_stmt that executes a Python while loop."""
    del opts, get_state, set_state
  
    if __debug__:
      checker = _PythonLoopChecker()
      before_iteration = checker.before_iteration
      after_iteration = checker.after_iteration
      before_iteration()
  
      original_body = body
      def protected_body():
        original_body()
        after_iteration()
        before_iteration()
      body = protected_body
  
    def guarded_test():
      test_result = test()
      try:
        # Note: Using try/except and not tensor_util.is_tf_type to avoid
        # performance degradation.
        return bool(test_result)
      except errors_impl.OperatorNotAllowedInGraphError as e:
        ag_logging.log(
            1,
            'Caught error while evaluating while loop condition',
            exc_info=True)
        # TODO(mdan): distinguish beteen these two cases.
        raise NotImplementedError(
            'The condition of while loop started as non-Tensor, then changed to'
            ' Tensor. This may happen either because variables changed type, or'
            ' when a break or return statement inside the loop depends on a'
            ' Tensor condition. In both cases, changing to a TF loop should'
            ' remove the error.\nSee '
            'https://github.com/tensorflow/tensorflow/blob/master/tensorflow/'
            'python/autograph/g3doc/reference/limitations.md'
            '#consistency-of-control-flow-types for more info.') from e
    while guarded_test():
      body()
function_tokens: def _py_while_stmt ( test , body , get_state , set_state , opts ) : del opts , get_state , set_state if __debug__ : checker = _PythonLoopChecker ( ) before_iteration = checker . before_iteration after_iteration = checker . after_iteration before_iteration ( ) original_body = body def protected_body ( ) : original_body ( ) after_iteration ( ) before_iteration ( ) body = protected_body def guarded_test ( ) : test_result = test ( ) try : # Note: Using try/except and not tensor_util.is_tf_type to avoid # performance degradation. return bool ( test_result ) except errors_impl . OperatorNotAllowedInGraphError as e : ag_logging . log ( 1 , 'Caught error while evaluating while loop condition' , exc_info = True ) # TODO(mdan): distinguish beteen these two cases. raise NotImplementedError ( 'The condition of while loop started as non-Tensor, then changed to' ' Tensor. This may happen either because variables changed type, or' ' when a break or return statement inside the loop depends on a' ' Tensor condition. In both cases, changing to a TF loop should' ' remove the error.\nSee ' 'https://github.com/tensorflow/tensorflow/blob/master/tensorflow/' 'python/autograph/g3doc/reference/limitations.md' '#consistency-of-control-flow-types for more info.' ) from e while guarded_test ( ) : body ( )