class_docstr: Check the ``__init__`` method of a given ``nn.Module``.
  
  It ensures that all instance-level attributes can be properly initialized.
  
  Specifically, we do type inference based on attribute values...even
  if the attribute in question has already been typed using
  Python3-style annotations or ``torch.jit.annotate``. This means that
  setting an instance-level attribute to ``[]`` (for ``List``),
  ``{}`` for ``Dict``), or ``None`` (for ``Optional``) isn't enough
  information for us to properly initialize that attribute.
  
  An object of this class can walk a given ``nn.Module``'s AST and
  determine if it meets our requirements or not.
  
  Known limitations
  1. We can only check the AST nodes for certain constructs; we can't
  ``eval`` arbitrary expressions. This means that function calls,
  class instantiations, and complex expressions that resolve to one of
  the "empty" values specified above will NOT be flagged as
  problematic.
  2. We match on string literals, so if the user decides to use a
  non-standard import (e.g. `from typing import List as foo`), we
  won't catch it.
  
  Example:
      .. code-block:: python
  
          class M(torch.nn.Module):
              def fn(self):
                  return []
  
              def __init__(self):
                  super().__init__()
                  self.x: List[int] = []
  
              def forward(self, x: List[int]):
                  self.x = x
                  return 1
  
      The above code will pass the ``AttributeTypeIsSupportedChecker``
      check since we have a function call in ``__init__``. However,
      it will still fail later with the ``RuntimeError`` "Tried to set
      nonexistent attribute: x. Did you forget to initialize it in
      __init__()?".
  
  Args:
      nn_module - The instance of ``torch.nn.Module`` whose
          ``__init__`` method we wish to check
code: def check(self, nn_module: torch.nn.Module) -> None:
      source_lines = inspect.getsource(nn_module.__class__.__init__)
  
      # Ignore comments no matter the indentation
      def is_useless_comment(line):
          line = line.strip()
          return line.startswith("#") and not line.startswith("# type:")
  
      source_lines = "\n".join(
          [
              l
              for l in source_lines.split("\n")
              if not is_useless_comment(l)
          ]
      )
  
      # This AST only contains the `__init__` method of the nn.Module
      init_ast = ast.parse(textwrap.dedent(source_lines))
  
      # Get items annotated in the class body
      self.class_level_annotations = list(
          nn_module.__annotations__.keys()
      )
  
      # Flag for later
      self.visiting_class_level_ann = False
  
      self.visit(init_ast)
  
file_path: pytorch/torch/jit/_check.py
imports: import ast
  import inspect
  import textwrap
  import warnings
  import torch
label_desc: Use image node_id 1 for calling the AttributeTypeIsSupportedChecker obj's underlying member method code with example usage: obj.check(nn_module) and returns: unknown