docstr: Test that DCE doesn't remove a module if it's specified as having side effects.
docstr_tok: ["Test","that","DCE","does","n't","remove","a","module","if","it","'s","specified","as","having","side","effects","."]
code: def test_keep_module_with_side_effects(self):
      """
      Test that DCE doesn't remove a module if it's specified as having side effects.
      """
  
      class ReLUImpure(torch.nn.ReLU):
          _is_impure = True
  
      class TestModule(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.relu = ReLUImpure()
  
          def forward(self, a: torch.Tensor) -> torch.Tensor:
              r = self.relu(a)
              return a * 2
  
      self._run_dce_and_test(
          TestModule(),
          expect_dce_changes=False,
          modules_to_be_leafs={ReLUImpure},
      )
  
file_path: pytorch/test/fx/test_dce_pass.py
imports: from typing import Set, Type
  import torch
  import torch.fx
  from torch.testing._internal.common_utils import TestCase
label_desc: Use image node_id 9 for calling the TestDCE obj's underlying member method code with example usage: obj.test_keep_module_with_side_effects() and returns: unknown