code: def _attempt_slice_retry(self, shard_state, tstate):
      
      if (shard_state.slice_retries + 1 <
          parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS):
        logging.warning(
            "Slice %s %s failed for the %s of up to %s attempts "
            "(%s of %s taskqueue execution attempts). "
            "Will retry now.",
            tstate.shard_id,
            tstate.slice_id,
            shard_state.slice_retries + 1,
            parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS,
            self.task_retry_count() + 1,
            parameters.config.TASK_MAX_ATTEMPTS)
        # Clear info related to current exception. Otherwise, the real
        # callstack that includes a frame for this method will show up
        # in log.
        sys.exc_clear()
        self._try_free_lease(shard_state, slice_retry=True)
        return self._TASK_DIRECTIVE.RETRY_SLICE
  
      if parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS > 0:
        logging.warning("Slice attempt %s exceeded %s max attempts.",
                        self.task_retry_count() + 1,
                        parameters.config.TASK_MAX_DATA_PROCESSING_ATTEMPTS)
      return self._TASK_DIRECTIVE.RETRY_SHARD
docs: Attempt to retry this slice.
  
      This method may modify shard_state and tstate to prepare for retry or fail.
  
      Args:
        shard_state: model.ShardState for current shard.
        tstate: model.TransientShardState for current shard.
  
      Returns:
        A _TASK_DIRECTIVE enum. RETRY_SLICE if slice should be retried.
      RETRY_SHARD if shard retry should be attempted.