class_docstr: A suite of tests for profile directed typing in TorchScript.
class_docstr_tok: ["A","suite","of","tests","for","profile","directed","typing","in","TorchScript","."]
code: def test_nested_nn_module_class(self):
      class NestedPDTInner(torch.nn.Module):
          def forward(self, x):
              if isinstance(x, int):
                  return x * 10
              return x
  
      class NestedModulePDTWrapper(torch.nn.Module):
          def __init__(self, inner):
              super().__init__()
              self.inner = inner
  
          def forward(self, x):
              return self.inner(x)
  
      make_global(NestedPDTInner, NestedModulePDTWrapper)
      inner_pdt_model = NestedPDTInner()
      wrapped_pdt_model = NestedModulePDTWrapper(inner_pdt_model)
      inp: List[Tuple[Any, ...]] = [(20,), (False,)]
      scripted_pdt_model = torch.jit.script(
          wrapped_pdt_model, example_inputs={wrapped_pdt_model: inp}
      )
      self.assertEqual(scripted_pdt_model(30), wrapped_pdt_model(30))
      self.assertEqual(scripted_pdt_model(1.9), wrapped_pdt_model(1.9))
      self.assertTrue(scripted_pdt_model(True), wrapped_pdt_model(True))
  
imports: import os
  import sys
  import torch
  from torch.testing._internal.jit_utils import JitTestCase, make_global
  from torch.jit._monkeytype_config import _IS_MONKEYTYPE_INSTALLED
  from typing import List, Dict, Tuple, Any, Optional, NamedTuple
  from torch.testing._internal.common_utils import NoTest
label_desc: Use image node_id 2 for calling the TestPDT obj's underlying member method code with example usage: obj.test_nested_nn_module_class() and returns: x, self, unknown