<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def try_checkpoint_metadata(self, trial):
 """Checkpoints metadata. Args: trial (Trial):
 Trial to checkpoint. """

        if trial._checkpoint.storage == Checkpoint.MEMORY:
            logger.debug("Not saving data for trial w/ memory checkpoint.")
            return
        try:
            logger.debug("Saving trial metadata.")
            self._cached_trial_state[trial.trial_id] = trial.__getstate__()
        except Exception:
            logger.exception("Error checkpointing trial metadata.")