parameters: (self, pred, body, loop_vars, shape_invariants)
return_statement: return (packed_exit_vars[0] if len(exit_vars) == 1
              else packed_exit_vars)
docstring: Add the loop termination condition and body to the graph.
docstring_summary: Add the loop termination condition and body to the graph.
docstring_tokens: Add the loop termination condition and body to the graph .
function: def BuildLoop(self, pred, body, loop_vars, shape_invariants):
      """Add the loop termination condition and body to the graph."""
  
      # Keep original_loop_vars to identify which are TensorArrays
      original_loop_vars = loop_vars
      # Convert TensorArrays to their flow variables
      loop_vars = nest.map_structure(_convert_tensorarray_to_flow,
                                     nest.flatten(loop_vars))
      loop_vars = ops.convert_n_to_tensor_or_indexed_slices(loop_vars)
      try:
        self.Enter()
        original_body_result, exit_vars = self._BuildLoop(
            pred, body, original_loop_vars, loop_vars, shape_invariants)
      finally:
        self.Exit()
  
      flat_result = nest.flatten(original_body_result)
      # Convert TensorArray flow variables outside the context back into
      # their associated TensorArrays for returning to caller.
      exit_vars_with_tensor_arrays = (
          _convert_flows_to_tensorarrays(flat_result, exit_vars))
      packed_exit_vars = nest.pack_sequence_as(
          structure=original_body_result,
          flat_sequence=exit_vars_with_tensor_arrays)
      return (packed_exit_vars[0] if len(exit_vars) == 1
              else packed_exit_vars)
function_tokens: def BuildLoop ( self , pred , body , loop_vars , shape_invariants ) : # Keep original_loop_vars to identify which are TensorArrays original_loop_vars = loop_vars # Convert TensorArrays to their flow variables loop_vars = nest . map_structure ( _convert_tensorarray_to_flow , nest . flatten ( loop_vars ) ) loop_vars = ops . convert_n_to_tensor_or_indexed_slices ( loop_vars ) try : self . Enter ( ) original_body_result , exit_vars = self . _BuildLoop ( pred , body , original_loop_vars , loop_vars , shape_invariants ) finally : self . Exit ( ) flat_result = nest . flatten ( original_body_result ) # Convert TensorArray flow variables outside the context back into # their associated TensorArrays for returning to caller. exit_vars_with_tensor_arrays = ( _convert_flows_to_tensorarrays ( flat_result , exit_vars ) ) packed_exit_vars = nest . pack_sequence_as ( structure = original_body_result , flat_sequence = exit_vars_with_tensor_arrays ) return ( packed_exit_vars [ 0 ] if len ( exit_vars ) == 1 else packed_exit_vars )