def replace_block_output_var(
            self,
            old_var,
            new_var,
    ):
        """
        If old_var is in the list of block's outputs,
        replace old_var with the new_var.
        """
        found_old_var_in_output = False
        # There could be multiple matched `old_var` in output when the program has duplicate vars
        # in the output.
        for idx, output_var in enumerate(self._outputs):
            if old_var == output_var:
                found_old_var_in_output = True
                self._outputs[idx] = new_var
        if found_old_var_in_output:
            new_var.consuming_blocks.append(self)
            # This block no longer uses `old_var` as its outputs
            old_var.consuming_blocks.remove(self)
            # Ensure output name is consistent
            if isinstance(self, Function):
                if new_var in self.inputs.values() and new_var.name != old_var.name:
                    raise ValueError("It is not allowed to modify function inputs name.")
                new_var.name = old_var.name

        If old_var is in the list of block's outputs,
        replace old_var with the new_var.
        
coremltools/converters/mil/mil/block.py