def save(self, model_file, save_dir, verbose=True):
<EOL>if not os.path.exists(save_dir):<EOL><INDENT>os.makedirs(save_dir)<EOL><DEDENT>params = {<EOL>"<STR_LIT>": self.state_dict(),<EOL>"<STR_LIT>": self.cardinality,<EOL>"<STR_LIT:name>": self.name,<EOL>"<STR_LIT>": self.settings,<EOL>}<EOL>try:<EOL><INDENT>torch.save(params, f"<STR_LIT>")<EOL><DEDENT>except BaseException:<EOL><INDENT>self.logger.warning("<STR_LIT>")<EOL><DEDENT>if verbose:<EOL><INDENT>self.logger.info(f"<STR_LIT>")<EOL><DEDENT>
Save current model.

        :param model_file: Saved model file name.
        :type model_file: str
        :param save_dir: Saved model directory.
        :type save_dir: str
        :param verbose: Print log or not
        :type verbose: bool