def test_duplicate_outputs_add_consuming_block_once():
    """The same consuming block should only be added once."""
    @mb.program(input_specs=[mb.TensorSpec(shape=(2, 4)), mb.TensorSpec(shape=(2, 4))])
    def prog(x0, y0):
        x1 = mb.add(x=x0, y=y0)
        return x1, x1, x1

    block = prog.functions["main"]
    assert len(block.outputs[0].consuming_blocks) == 1
    assert len(block.outputs[1].consuming_blocks) == 1
    assert len(block.outputs[2].consuming_blocks) == 1
The same consuming block should only be added once.
coremltools/converters/mil/mil/tests/test_block.py