code: def test_remove_duplicate_ops():
      """Test remove duplicated ops."""
  
      @mb.program(input_specs=[mb.TensorSpec(shape=(2, 4))])
      def prog(x0):
          x1 = mb.add(x=x0, y=x0)
          return x1
  
      block = prog.functions["main"]
      x0 = block.inputs["x0"]
      ops = block.find_ops(op_type="add")
      duplicate_ops = ops + ops
      block.set_outputs([x0])
      block.remove_ops(duplicate_ops)
      assert len(block.operations) == 0
      assert len(block.inputs) == 1
      assert len(block.outputs) == 1
      assert block.inputs["x0"] == block.outputs[0]
  
imports: import copy
  import numpy
  import pytest
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil.passes.tests.test_passes import CONSTEXPR_FUNCS
  from coremltools.converters.mil.testing_utils import assert_same_output_names, assert_same_output_shapes, get_op_types_in_program
label_desc: Use image node_id 5 for calling a global function with example usage: test_remove_duplicate_ops() and returns: x1