    def test_all_interactions(self):
        """Test all interactions:
        1. Fusing duplicates
        2. Fusing duplicates with accessors that write to a concat's output tensor
        3. Avoid fusing non-duplicates
        """
        x = gen_input_tensor(shape=self.SHAPE, name="input_x")
        z = gen_input_tensor(shape=self.SHAPE, name="input_z")
        p = gen_input_tensor(shape=self.SHAPE, name="input_p")

        # First ReLU op with x as the input.
        relu1 = ops.elementwise(FuncEnum.RELU)(x)
        tanh = ops.elementwise(FuncEnum.TANH)(relu1)
        concat1 = ops.concatenate()([relu1, tanh])

        # Fuse relu2 with relu1. This ReLU uses a tensor accessor to write
        # directly to concat2's output.
        relu2 = ops.elementwise(FuncEnum.RELU)(x)
        concat2 = ops.concatenate()([relu2, p])

        # Fuse relu3 with relu1.
        relu3 = ops.elementwise(FuncEnum.RELU)(x)
        softmax = ops.softmax()(relu3, dim=0)
        concat3 = ops.concatenate()([softmax, softmax])

        # Don't fuse operators with different input or elementwise-ops.
        gelu = ops.elementwise(FuncEnum.GELU)(x)
        relu4 = ops.elementwise(FuncEnum.RELU)(z)
        concat4 = ops.concatenate()([relu4, gelu])

        model_output = concat1 + concat2 + concat3 + concat4
        model_output._attrs["is_output"] = True
        model_output._attrs["name"] = "output"

        # Setup PyTorch
        x_pt = get_random_torch_tensor(self.SHAPE)
        z_pt = get_random_torch_tensor(self.SHAPE)
        p_pt = get_random_torch_tensor(self.SHAPE)

        relu1_pt = torch.nn.functional.relu(x_pt)
        tanh_pt = torch.nn.functional.tanh(relu1_pt)
        concat1_pt = torch.concat([relu1_pt, tanh_pt])

        relu2_pt = torch.nn.functional.relu(x_pt)
        concat2_pt = torch.concat([relu2_pt, p_pt])

        relu3_pt = torch.nn.functional.relu(x_pt)
        softmax_pt = torch.nn.functional.softmax(relu3_pt, dim=0)
        concat3_pt = torch.concat([softmax_pt, softmax_pt])

        relu4_pt = torch.nn.functional.relu(z_pt)
        gelu_pt = torch.nn.functional.gelu(x_pt)
        concat4_pt = torch.concat([relu4_pt, gelu_pt])

        y_pt = concat1_pt + concat2_pt + concat3_pt + concat4_pt
        y_ait = torch.empty_like(y_pt)

        with compile_model(
            model_output,
            detect_target(),
            "/tmp",
            "fuse_duplicate_fused_elementwise_all_interactions",
        ) as module:
            module.run_with_tensors(
                inputs={
                    "input_x": x_pt,
                    "input_z": z_pt,
                    "input_p": p_pt,
                },
                outputs={"output": y_ait},
            )
            graph = module.debug_sorted_graph
            nrelu = self._count_fused_elementwise_ops(graph, [FuncEnum.RELU])
            ngelu = self._count_fused_elementwise_ops(graph, [FuncEnum.GELU])
            self.assertEqual(nrelu, 2)
            self.assertEqual(ngelu, 1)
            self.assertTrue(torch.allclose(y_pt, y_ait, atol=1e-2, rtol=1e-2))
Test all interactions:
1. Fusing duplicates
2. Fusing duplicates with accessors that write to a concat's output tensor
3. Avoid fusing non-duplicates
tests/unittest/compiler/test_fuse_duplicate_fused_elementwise.py