class_docstr: Tests for TorchScript support of Python builtin functions.
code: def test_has_attr(self):
      class HasA(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.a = 0
  
      class HasB(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.b = 1
  
      class Mod(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.mods = torch.nn.ModuleList([HasA(), HasB()])
  
          def forward(self):
              # use a list to encode hasattr results
              l = torch.jit.annotate(List[int], [])
              for mod in self.mods:
                  l.append(int(hasattr(mod, "a")))
                  l.append(int(hasattr(mod, "b")))
                  # actually retrieve the attr to test static refinement
                  if hasattr(mod, "a"):
                      l.append(mod.a)
                  if hasattr(mod, "b"):
                      l.append(mod.b)
              return l
  
      self.checkModule(Mod(), ())
  
imports: import os
  import sys
  import inspect
  import unittest
  from typing import Dict, List
  import torch
  from torch.testing import FileCheck
  from torch.testing._internal.jit_utils import JitTestCase, RUN_CUDA
label_desc: Use image node_id 1 for calling the TestBuiltins obj's underlying member method code with example usage: obj.test_has_attr() and returns: l