code: def set_status(self, trial, status):
          
          trial.status = status
          if status in [Trial.TERMINATED, Trial.ERROR]:
              self.try_checkpoint_metadata(trial)
docs: Sets status and checkpoints metadata if needed.
  
          Only checkpoints metadata if trial status is a terminal condition.
          PENDING, PAUSED, and RUNNING switches have checkpoints taken care of
          in the TrialRunner.
  
          Args:
              trial (Trial): Trial to checkpoint.
              status (Trial.status): Status to set trial to.