code: def save(self, checkpoint_dir=None):
          
  
          checkpoint_dir = os.path.join(checkpoint_dir or self.logdir,
                                        "checkpoint_{}".format(self._iteration))
          if not os.path.exists(checkpoint_dir):
              os.makedirs(checkpoint_dir)
          checkpoint = self._save(checkpoint_dir)
          saved_as_dict = False
          if isinstance(checkpoint, string_types):
              if (not checkpoint.startswith(checkpoint_dir)
                      or checkpoint == checkpoint_dir):
                  raise ValueError(
                      "The returned checkpoint path must be within the "
                      "given checkpoint dir {}: {}".format(
                          checkpoint_dir, checkpoint))
              if not os.path.exists(checkpoint):
                  raise ValueError(
                      "The returned checkpoint path does not exist: {}".format(
                          checkpoint))
              checkpoint_path = checkpoint
          elif isinstance(checkpoint, dict):
              saved_as_dict = True
              checkpoint_path = os.path.join(checkpoint_dir, "checkpoint")
              with open(checkpoint_path, "wb") as f:
                  pickle.dump(checkpoint, f)
          else:
              raise ValueError(
                  "`_save` must return a dict or string type: {}".format(
                      str(type(checkpoint))))
          with open(checkpoint_path + ".tune_metadata", "wb") as f:
              pickle.dump({
                  "experiment_id": self._experiment_id,
                  "iteration": self._iteration,
                  "timesteps_total": self._timesteps_total,
                  "time_total": self._time_total,
                  "episodes_total": self._episodes_total,
                  "saved_as_dict": saved_as_dict
              }, f)
          return checkpoint_path
docs: Saves the current model state to a checkpoint.
  
          Subclasses should override ``_save()`` instead to save state.
          This method dumps additional metadata alongside the saved path.
  
          Args:
              checkpoint_dir (str): Optional dir to place the checkpoint.
  
          Returns:
              Checkpoint path that may be passed to restore().