def get_fully_qualified_name(model: _torch.nn.Module, module: _torch.nn.Module) -> str:
    """
    Returns fully qualified name for a module if it exists in the model. The fully qualified
    name can be used to fetch the module using ``model.get_submodule``.
    """
    for mod_name, mod in model.named_modules(remove_duplicate=True):
        if mod == module:
            return mod_name
    raise ValueError(f"Module: {module} is not a submodule of {model}.")

    Returns fully qualified name for a module if it exists in the model. The fully qualified
    name can be used to fetch the module using ``model.get_submodule``.
    
coremltools/optimize/torch/_utils/torch_utils.py