def test_extract_submodel_complex(self):
        """
        Input graph:
        x -> sin ------> sub -> output_1
              |      |
              v      v
        y -> add -> mul -> tan -> realdiv -> output_2
        """
        @mb.program(input_specs=[mb.TensorSpec(shape=(1, 2)), mb.TensorSpec(shape=(1, 2))])
        def prog(x, y):
            sin = mb.sin(x=x, name="sin")
            add = mb.add(x=sin, y=y, name="add")
            sub = mb.sub(x=sin, y=1.5, name="sub")
            mul = mb.mul(x=sin, y=add, name="mul")
            tan = mb.tan(x=mul, name="tan")
            realdiv = mb.real_div(x=tan, y=4.7, name="realdiv")
            return sub, realdiv
        model = ct.convert(prog, convert_to="neuralnetwork")

        """
        Case 1:
        inputs = None
        outputs = [sin, mul]

        Output graph:
        x -> sin ------> output_1
              |      |
              v      v
        y -> add -> mul -> output_2
        """
        submodel = extract_submodel(model, outputs=["sin", "mul"])
        assert get_op_types_in_program(submodel._mil_program) == ["sin", "add", "mul"]

        """
        Case 2:
        inputs = None
        outputs = [sin, add]

        Output graph:
        x -> sin -> output_1
              |
              v
        y -> add -> output_2
        """
        submodel = extract_submodel(model, outputs=["sin", "add"])
        assert get_op_types_in_program(submodel._mil_program) == ["sin", "add"]

        """
        Case 3:
        inputs = None
        outputs = [mul]

        Output graph:
        x -> sin -----
              |      |
              v      v
        y -> add -> mul -> output_1
        """
        submodel = extract_submodel(model, outputs=["mul"])
        assert get_op_types_in_program(submodel._mil_program) == ["sin", "add", "mul"]

        """
        Case 4:
        inputs = None
        outputs = [sin, sub]

        Output graph:
        x -> sin -> sub -> output_2
              |
              V
           output_1
        y
        """
        submodel = extract_submodel(model, outputs=["sin", "sub"])
        assert get_op_types_in_program(submodel._mil_program) == ["sin", "sub"]

        """
        Case 5:
        inputs = [x, y]
        outputs = [mul]

        Output graph:
        x -> sin -----
              |      |
              v      v
        y -> add -> mul -> output_1
        """
        submodel = extract_submodel(model, outputs=["mul"], inputs=["x", "y"])
        assert get_op_types_in_program(submodel._mil_program) == ["sin", "add", "mul"]

        """
        Case 6:
        inputs = [mul]
        outputs = [tan]

        mul -> tan -> output_1
        """
        submodel = extract_submodel(model, outputs=["tan"], inputs=["mul"])
        assert get_op_types_in_program(submodel._mil_program) == ["tan"]

        """
        Case 7:
        inputs = [sin, add]
        outputs = [sub, mul]

        sin ------> sub -> output_1
                |
                v
        add -> mul -> output_2
        """
        submodel = extract_submodel(model, outputs=["sub", "mul"], inputs=["sin", "add"])
        assert get_op_types_in_program(submodel._mil_program) == ["sub", "mul"]

        """
        Case 8 (Negative):
        inputs = [sin]
        outputs = [mul]

        mul not reachable merely through sin
        """
        with pytest.raises(ValueError, match="output mul not reachable from inputs"):
            submodel = extract_submodel(model, outputs=["mul"], inputs=["sin"])

        """
        Case 9 (Negative):
        inputs = [mul]
        outputs = [sin]

        sin not reachable merely through sin
        """
        with pytest.raises(ValueError, match="output sin not reachable from inputs"):
            submodel = extract_submodel(model, outputs=["sin"], inputs=["mul"])

        Input graph:
        x -> sin ------> sub -> output_1
              |      |
              v      v
        y -> add -> mul -> tan -> realdiv -> output_2
        
coremltools/converters/mil/mil/tests/test_debug.py