def unwrap_model(model: nn.Module) -> nn.Module:
    """
    Unwraps a model from potential containers (as used in distributed training).

    Args:
        model (`torch.nn.Module`): The model to unwrap.
    """
    # since there could be multiple levels of wrapping, unwrap recursively
    if hasattr(model, "module"):
        return model.module
    else:
        return model
Unwraps a model from potential containers (as used in distributed training).

Args:
model (`torch.nn.Module`): The model to unwrap.
towhee/trainer/utils/trainer_utils.py