def test_external_tensor_is_output(self, test_name="external_tensor_is_output"):
        """
        Case: The intermediate tensor is a view of an output.
        Graph: ( output_0 ) <--view-- ( intermediate ) <--view-- ( output_1 )
        """
        x = gen_input_tensor(shape=self.SHAPE, name="input_x")
        z = gen_input_tensor(shape=self.SHAPE, name="input_z")
        output0 = ops.elementwise(FuncEnum.RELU)(x + z)
        output0._attrs["is_output"] = True
        output0._attrs["name"] = "output_0"

        intermediate_view = ops.unsqueeze(dim=0)(output0)  # has an output alias
        output1 = ops.flatten()(intermediate_view)
        output1._attrs["is_output"] = True
        output1._attrs["name"] = "output_1"

        compile_model(
            [output0, output1],
            detect_target(),
            self.WORKDIR,
            test_name,
            do_optimize_graph=False,
        )
        intermediate_name = intermediate_view._attrs["name"]
        expected_codegen = (
            # input_z is assigned to params_[0].ptr
            # input_x is assigned to params_[1].ptr
            set_value(
                "output_0",
                "static_cast<decltype(output_0)>(params_[2].ptr)",
            ),
            set_value(intermediate_name, "output_0"),
        )
        self._assert_codegen_exists(
            test_name, expected_codegen, self.MODEL_GENERATED_FILE
        )

        Case: The intermediate tensor is a view of an output.
        Graph: ( output_0 ) <--view-- ( intermediate ) <--view-- ( output_1 )
        
tests/unittest/backend/test_codegen_output_aliases.py