import copy


def build(cfg, registry, args=None):
    """
    Build the module with cfg.
    Args:
        cfg (dict): the config of the modules
        registry(Registry): A registry the module belongs to.
    
    Returns:
        The built module.
    """
    args = copy.deepcopy(cfg)
    name = args.pop("name")
    ret = registry.get(name)(**args)
    return ret