docstr: Test that module attributes can be ignored.
docstr_tok: ["Test","that","module","attributes","can","be","ignored","."]
code: def test_ignoring_module_attributes(self):
      """
      Test that module attributes can be ignored.
      """
  
      class Sub(torch.nn.Module):
          def forward(self, a: int) -> int:
              return sum([a])
  
      class ModuleWithIgnoredAttr(torch.nn.Module):
          __jit_ignored_attributes__ = ["a", "sub"]
  
          def __init__(self, a: int, b: int):
              super().__init__()
              self.a = a
              self.b = b
              self.sub = Sub()
  
          def forward(self) -> int:
              return self.b
  
          @torch.jit.ignore
          def ignored_fn(self) -> int:
              return self.sub.forward(self.a)
  
      mod = ModuleWithIgnoredAttr(1, 4)
      scripted_mod = torch.jit.script(mod)
      self.assertEqual(scripted_mod(), 4)
      self.assertEqual(scripted_mod.ignored_fn(), 1)
  
      # Test the error message for ignored attributes.
      class ModuleUsesIgnoredAttr(torch.nn.Module):
          __jit_ignored_attributes__ = ["a", "sub"]
  
          def __init__(self, a: int):
              super().__init__()
              self.a = a
              self.sub = Sub()
  
          def forward(self) -> int:
              return self.sub(self.b)
  
      mod = ModuleUsesIgnoredAttr(1)
  
      with self.assertRaisesRegexWithHighlight(
          RuntimeError,
          r"attribute was ignored during compilation",
          "self.sub",
      ):
          scripted_mod = torch.jit.script(mod)
  
imports: from collections import namedtuple
  from typing import Dict, Iterator, List, Optional, Tuple
  from torch.testing._internal.jit_utils import JitTestCase
  from torch.testing import FileCheck
  from textwrap import dedent
  from jit.test_module_interface import TestModuleInterface
  import inspect
  import os
  import sys
  import torch
  import torch.testing._internal.jit_utils
label_desc: Use image node_id 9 for calling the TestTypesAndAnnotation obj's underlying member method code with example usage: obj.test_ignoring_module_attributes() and returns: sum, self, self, self