def set_attr(module, attr, submodule, fail_on_not_found=False):
    """Set attribute from module.

    :param module: module to set
    :param attr: attribute name, can be a string with dot notation.
    :param submodule: submodule to set.
    :param fail_on_not_found: if True, raise AttributeError if attribute is not found.
    """
    parent_name = ".".join(attr.split(".")[:-1])
    parent_module = get_attr(module, parent_name, fail_on_not_found)
    target_name = attr.split(".")[-1]

    setattr(parent_module, target_name, submodule)
Set attribute from module.

    :param module: module to set
    :param attr: attribute name, can be a string with dot notation.
    :param submodule: submodule to set.
    :param fail_on_not_found: if True, raise AttributeError if attribute is not found.
    
olive/common/utils.py