def ensure_directory_exists(filename):
    """Create the directory path to ``filename`` if it does not already exist.

    Args:
        filename (str): A file path.
    """
    dirname = os.path.dirname(filename)
    os.makedirs(dirname, exist_ok=True)
Create the directory path to ``filename`` if it does not already exist.

Args:
filename (str): A file path.
opensora/adaptor/utils.py