def populate_native_const_model_hierarchy(graph: InternalTorchIRGraph) -> None:
    """
    Torchscript doesn't capture the model hierarchy of those python native consts.
    For instance:

    class Submodule(torch.nn.Module):
        def forward(self, x):
            x = x + 0.9
            x = x * 0.9
            return torch.relu(x)

    class Model(torch.nn.Module):
        def __init__(self):
            super().__init__()
            self.submodule_1 = Submodule()

        def forward(self, x):
            return self.submodule_1(x)

    The two ``0.9`` constants don't have the scope of Submodule.
    In this graph pass, we make the model hierarchy of such constants inherited from
    their child ops.
    """

    cached_model_hierarchy = {}
    child_ops = defaultdict(list)

    for node in graph.nodes:
        for b in node.blocks:
            populate_native_const_model_hierarchy(b)

    for node in graph.nodes:
        cached_model_hierarchy[node.name] = node.model_hierarchy
        for val in node.inputs:
            child_ops[val].append(node.name)

    for node in graph.nodes:
        if node.kind != "constant":
            continue
        if node.model_hierarchy == "" and len(child_ops[node.name]) == 1:
            node.model_hierarchy = cached_model_hierarchy[child_ops[node.name][0]]

    Torchscript doesn't capture the model hierarchy of those python native consts.
    For instance:

    class Submodule(torch.nn.Module):
        def forward(self, x):
            x = x + 0.9
            x = x * 0.9
            return torch.relu(x)

    class Model(torch.nn.Module):
        def __init__(self):
            super().__init__()
            self.submodule_1 = Submodule()

        def forward(self, x):
            return self.submodule_1(x)

    The two ``0.9`` constants don't have the scope of Submodule.
    In this graph pass, we make the model hierarchy of such constants inherited from
    their child ops.
    
coremltools/converters/mil/frontend/torch/torchir_passes.py