docstr: Remove ops in `existing_ops`.
  
  Args: existing_ops: List[Operation]. All ops in this list must be pre-existing in the
  block. It allows duplicated ops, but duplicated ops will only be removed once.
  
  Raises:
      ValueError if any `op` in `existing_ops` meets any of following conditions:
        - `op` is not found in the block
        - any other op in the block uses output Vars of `op`
        - the output var is block's output
docstr_tok: ["Remove","ops","in","`","existing_ops","`",".","Args",":","existing_ops",":","List","[","Operation","]",".","All","ops","in","this","list","must","be","pre-existing","in","the","block",".","It","allows","duplicated","ops",",","but","duplicated","ops","will","only","be","removed","once",".","Raises",":","ValueError","if","any","`","op","`","in","`","existing_ops","`","meets","any","of","following","conditions",":","-","`","op","`","is","not","found","in","the","block","-","any","other","op","in","the","block","uses","output","Vars","of","`","op","`","-","the","output","var","is","block","'s","output"]
code: def remove_ops(self, existing_ops):
      """
      Remove ops in `existing_ops`.
  
      Args: existing_ops: List[Operation]. All ops in this list must be pre-existing in the
      block. It allows duplicated ops, but duplicated ops will only be removed once.
  
      Raises:
          ValueError if any `op` in `existing_ops` meets any of following conditions:
            - `op` is not found in the block
            - any other op in the block uses output Vars of `op`
            - the output var is block's output
      """
      self.validate()
  
      # Dedup ops because each op can only be deleted once.
      existing_ops_set = set(existing_ops)
      existing_ops = list(existing_ops_set)
      # Find the idx of each to-be-removed op, and raise errors if any op couldn't be found.
      idxs = [-1] * len(existing_ops)
      for i, op in enumerate(self.operations):
          if op in existing_ops_set:
              idxs[existing_ops.index(op)] = i
      if -1 in idxs:
          not_found = []
          for i, op in zip(idxs, existing_ops):
              if i == -1:
                  not_found.append(op.name)
          raise ValueError(
              "Ops {} not found in block {}".format(
                  not_found, self.name
              )
          )
  
      # Remove ops in reverse topological order
      pairs = list(zip(idxs, existing_ops))
      pairs.sort(key=lambda x: x[0], reverse=True)
  
      for idx, op in pairs:
          for i, v in enumerate(op.outputs):
              # Check that no ops depend on op's outputs
              if len(v.child_ops) > 0:
                  child_op_names = [s.name for s in v.child_ops]
                  msg = (
                      "Cannot delete op '{}' with active output at id {}: '{}' "
                      + "used by ops {}"
                  )
                  raise ValueError(
                      msg.format(op.name, i, v.name, child_op_names)
                  )
              # Check that the output Var isn't block's output
              if v in self._outputs:
                  msg = (
                      "cannot delete op {} with output {}: {} "
                      + "that's block {}'s output"
                  )
                  raise ValueError(
                      msg.format(op.name, i, v.name, self.name)
                  )
  
          for b in op.blocks:
              b.set_outputs([])
              b.remove_ops(b.operations)
  
          # Remove the op (in reverse topological order)
          self.operations.pop(idx)
          op.enclosing_block = None
  
          for v in op.inputs.values():
              if isinstance(v, (tuple, list)):
                  for vv in v:
                      vv.remove_child_op(op)
              else:
                  v.remove_child_op(op)
  
imports: import copy
  from collections import Counter, OrderedDict
  from typing import Tuple
  from coremltools import _OPSET
  from coremltools import _logger
  from coremltools.converters.mil._deployment_compatibility import AvailableTarget
  from .None import SPACES, types
  from .operation import Operation
  from .types.symbolic import is_symbolic, k_used_symbols
  from .var import ComplexVar, InternalVar, Var
  from .visitors.dot_visitor import DotVisitor
label_desc: Use image node_id 19 for calling the Block obj's underlying member method code with example usage: obj.remove_ops(existing_ops) without return types