code: def _stop_trial(self, trial, error=False, error_msg=None,
                      stop_logger=True):
          
  
          if stop_logger:
              trial.close_logger()
  
          if error:
              self.set_status(trial, Trial.ERROR)
          else:
              self.set_status(trial, Trial.TERMINATED)
  
          try:
              trial.write_error_log(error_msg)
              if hasattr(trial, "runner") and trial.runner:
                  if (not error and self._reuse_actors
                          and self._cached_actor is None):
                      logger.debug("Reusing actor for {}".format(trial.runner))
                      self._cached_actor = trial.runner
                  else:
                      logger.info(
                          "Destroying actor for trial {}. If your trainable is "
                          "slow to initialize, consider setting "
                          "reuse_actors=True to reduce actor creation "
                          "overheads.".format(trial))
                      trial.runner.stop.remote()
                      trial.runner.__ray_terminate__.remote()
          except Exception:
              logger.exception("Error stopping runner for Trial %s", str(trial))
              self.set_status(trial, Trial.ERROR)
          finally:
              trial.runner = None
docs: Stops this trial.
  
          Stops this trial, releasing all allocating resources. If stopping the
          trial fails, the run will be marked as terminated in error, but no
          exception will be thrown.
  
          Args:
              error (bool): Whether to mark this trial as terminated in error.
              error_msg (str): Optional error message.
              stop_logger (bool): Whether to shut down the trial logger.