def save_model(self, global_step=None, full_name=None):
        """
        save the trained model.

        Args:
            global_step (int, optional): The number of steps that the model has been
                finetuned for. Defaults to None.
            full_name (str, optional): File name to save the model's `state_dict()`.
                If it's None, the model is going to be saved under "fine_tuned" folder
                of the cached directory of the object. Defaults to None.
        """
        model_to_save = (
            self.model.module if hasattr(self.model, "module") else self.model
        )  # Take care of distributed/parallel training

        if full_name is None:
            output_model_dir = os.path.join(self.cache_dir, "fine_tuned")
            os.makedirs(self.cache_dir, exist_ok=True)
            os.makedirs(output_model_dir, exist_ok=True)
            full_name = os.path.join(output_model_dir, "bertsumabs.pt")
        else:
            path, filename = os.path.split(full_name)
            print(path)
            os.makedirs(path, exist_ok=True)

        checkpoint = {
            "optimizers": [self.optim_bert.state_dict(), self.optim_dec.state_dict()],
            "model": model_to_save.state_dict(),
            "amp": self.amp.state_dict() if self.amp else None,
            "global_step": global_step,
            "max_pos_length": self.max_pos_length,
        }

        logger.info("Saving model checkpoint to %s", full_name)
        try:
            print("saving through pytorch to {}".format(full_name))
            torch.save(checkpoint, full_name)
        except OSError:
            try:
                print("saving as pickle")
                pickle.dump(checkpoint, open(full_name, "wb"))
            except Exception:
                raise
        except Exception:
            raise

        save the trained model.

        Args:
            global_step (int, optional): The number of steps that the model has been
                finetuned for. Defaults to None.
            full_name (str, optional): File name to save the model's `state_dict()`.
                If it's None, the model is going to be saved under "fine_tuned" folder
                of the cached directory of the object. Defaults to None.
        
utils_nlp/models/transformers/abstractive_summarization_bertsum.py