def test_add_graph_pass_scope():
        """
        Test the rules of merging two scopes.
        """
        # Rule of merging COREMLTOOLS_GRAPH_PASS
        old_scopes = {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }
        new_scopes = {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_2", "pass_3"],
        }
        res = dict(add_graph_pass_scope(old_scopes, new_scopes))

        assert res == {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1", "pass_2", "pass_3"],
        }

        # Ensure we make a copy of the list
        old_scopes[ScopeSource.COREMLTOOLS_GRAPH_PASS][0] = "invalid"
        assert res == {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1", "pass_2", "pass_3"],
        }
        new_scopes[ScopeSource.COREMLTOOLS_GRAPH_PASS][0] = "invalid"
        assert res == {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1", "pass_2", "pass_3"],
        }

        # Another test
        old_scopes = {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_1"],
            ScopeSource.TORCHSCRIPT_MODULE_NAME: ["a1"],
        }
        new_scopes = {
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }
        res = add_graph_pass_scope(old_scopes, new_scopes)

        assert res == {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_1"],
            ScopeSource.TORCHSCRIPT_MODULE_NAME: ["a1"],
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }

        # Ensure we make a copy of the list
        old_scopes[ScopeSource.TORCHSCRIPT_MODULE_TYPE][0] = "invalid"
        assert res == {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_1"],
            ScopeSource.TORCHSCRIPT_MODULE_NAME: ["a1"],
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }
        old_scopes[ScopeSource.TORCHSCRIPT_MODULE_NAME][0] = "invalid"
        assert res == {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_1"],
            ScopeSource.TORCHSCRIPT_MODULE_NAME: ["a1"],
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }

        # Test for other scope source
        old_scopes = {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_1"],
            ScopeSource.TORCHSCRIPT_MODULE_NAME: ["a1"],
            ScopeSource.COREMLTOOLS_GRAPH_PASS: ["pass_1"],
        }
        new_scopes = {
            ScopeSource.TORCHSCRIPT_MODULE_TYPE: ["module_2"],
        }

        with pytest.raises(
            AssertionError,
            match="Only ScopeSource.COREMLTOOLS_GRAPH_PASS is allowed in the graph_pass_scopes.",
        ):
            add_graph_pass_scope(old_scopes, new_scopes)

        Test the rules of merging two scopes.
        
coremltools/converters/mil/mil/tests/test_programs.py