def get_is_saving_process(cfg: dict):
    """
    Check if the current process is the one that saves the model.

    Args:
        plugin_config (dict): Plugin configuration.

    Returns:
        bool: True if the current process is the one that saves the model.
    """
    plugin_type = cfg.get("plugin", "zero2")
    plugin_config = cfg.get("plugin_config", {})
    is_saving_process = (
        plugin_type != "hybrid"
        or (plugin_config["tp_size"] > 1 and dist.get_rank(get_tensor_parallel_group()) == 0)
        or (plugin_config["sp_size"] > 1 and dist.get_rank(get_sequence_parallel_group()) == 0)
    )
    return is_saving_process

    Check if the current process is the one that saves the model.

    Args:
        plugin_config (dict): Plugin configuration.

    Returns:
        bool: True if the current process is the one that saves the model.
    
opensora/utils/cai.py