def need_rewrite(self, context):
        context.rnn_scope = get_rnn_scope_name(context.while_context_scope)

        if not parse_rnn_loop(self.g, context.loop_properties,
                              context.rnn_scope, context.while_context_scope):
            logger.debug("parse_rnn_loop failed, SKIP")
            return False

        if not self.parse_unit_rnn(context):
            logger.debug("failed to parse unit rnn, SKIP")
            return False

        if not self.is_valid(context):
            logger.debug("parsed rnn is not valid, SKIP")
            return False
        return True
    def need_rewrite(self, context):
        context.rnn_scope = get_rnn_scope_name(context.while_context_scope)

        res = parse_rnn_loop(self.g, context.loop_properties, context.rnn_scope,
                             context.while_context_scope)
        if not res:
            logger.debug("skip the loop due to parse_rnn_loop failed")
            return False

        time_var, iteration_var = res
        context.time_var = time_var
        context.iteration_var = iteration_var
        logger.debug("time var %s - enter input id (%s) shape: %s, output (%s) shape: %s", time_var.enter_name,
                     time_var.enter_input_id, self.g.get_shape(time_var.enter_input_id),
                     time_var.switch_true_identity_output.id, time_var.switch_true_identity_output.shape)

        return True