    def save_to_yaml(self, path2yaml: str = None):
        """
        Save training configuration to yaml.

        Args:
            path2yaml (`str`):
                The path to yaml.

        Example:
            >>> from towhee.trainer.training_config import TrainingConfig
            >>> from pathlib import Path
            >>> conf = Path(__file__).parent / 'config.yaml'
            >>> ta = TrainingConfig()
            >>> ta.save_to_yaml(conf)
            >>> ta.load_from_yaml(conf)
            >>> ta.epoch_num
            2
        """
        config_dict = {}
        for config_category in self.config_category_set:
            config_dict[config_category] = {}
        config_fields = fields(TrainingConfig)
        for config_field in config_fields:
            metadata_dict = config_field.metadata
            field_name = config_field.name
            if CATEGORY in metadata_dict:
                category = metadata_dict[CATEGORY]
                config_dict[category][field_name] = _get_attr_str(self, field_name)
            else:
                config_dict[OTHER_CATEGORY][field_name] = _get_attr_str(self, field_name)
                trainer_log.warning("metadata in self.%s has no CATEGORY", config_field.name)
        with open(path2yaml, "w", encoding="utf-8") as file:
            dump_yaml(config_dict, file)
Save training configuration to yaml.

Args:
path2yaml (`str`):
The path to yaml.

Example:
>>> from towhee.trainer.training_config import TrainingConfig
>>> from pathlib import Path
>>> conf = Path(__file__).parent / 'config.yaml'
>>> ta = TrainingConfig()
>>> ta.save_to_yaml(conf)
>>> ta.load_from_yaml(conf)
>>> ta.epoch_num
2
towhee/trainer/training_config.py