def test_const_deduplication_cross_functions_from_same_source(self):
        """
        In the case of users copying a source function into two functions,
        same weight should be assigned with the same weighr_id as well.
        """
        val_1 = np.random.rand(
            100,
        )
        val_2 = np.random.rand(
            100,
        )
        val_3 = np.random.rand(
            100,
        )

        @mb.function(
            input_specs=[mb.TensorSpec((100,))],
        )
        def func(x):
            const_1 = mb.const(val=val_1)
            const_2 = mb.const(val=val_1)
            const_3 = mb.const(val=val_2)
            const_4 = mb.const(val=val_3)

            x = mb.add(x=x, y=const_1)
            x = mb.add(x=x, y=const_2)
            x = mb.add(x=x, y=const_3)
            return mb.add(x=x, y=const_4)

        prog = mil.Program()
        prog.add_function("func_1", func)
        prog.add_function("func_2", func)

        graph_pass = PASS_REGISTRY["common::const_deduplication"]
        graph_pass._deduplicate_const_across_functions(prog)

        # validate the prog
        func_1 = prog.functions["func_1"]
        expected_ops = ["const", "const", "const", "add", "add", "add", "add"]
        assert get_op_types_in_block(func_1, skip_const_ops=False) == expected_ops
        func_2 = prog.functions["func_2"]
        assert get_op_types_in_block(func_2, skip_const_ops=False) == expected_ops

        for func in [prog.functions["func_1"], prog.functions["func_2"]]:
            const_ops = func.find_ops(op_type="const")
            assert const_ops[0].weight_id == "0"
            assert const_ops[1].weight_id == "1"
            assert const_ops[2].weight_id == "2"

        In the case of users copying a source function into two functions,
        same weight should be assigned with the same weighr_id as well.
        
coremltools/converters/mil/mil/passes/tests/test_cleanup_passes.py