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_with_args(self):
      class NestedModulePDTInner(torch.nn.Module):
          def forward(self, x, y):
              if isinstance(x, int):
                  return x * 10 + y
              return x
  
      class NestedModulePDTOuter(torch.nn.Module):
          def __init__(self, inner):
              super().__init__()
              self.inner = inner
  
          def forward(self, x):
              return self.inner(x, 20)
  
      make_global(NestedModulePDTInner, NestedModulePDTOuter)
      inner_pdt_model = NestedModulePDTInner()
      outer_pdt_model = NestedModulePDTOuter(inner_pdt_model)
      inner_input: List[Tuple[Any, ...]] = [
          (10, 10),
          (1.9, 20),
      ]
      outer_input: List[Tuple[Any, ...]] = [(20,), (False,)]
      scripted_pdt_model = torch.jit.script(
          outer_pdt_model,
          example_inputs={
              inner_pdt_model: inner_input,
              outer_pdt_model: outer_input,
          },
      )
      self.assertEqual(scripted_pdt_model(30), outer_pdt_model(30))
      self.assertEqual(scripted_pdt_model(1.9), outer_pdt_model(1.9))
      self.assertTrue(scripted_pdt_model(True), outer_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 3 for calling the TestPDT obj's underlying member method code with example usage: obj.test_nested_nn_module_class_with_args() and returns: x, self, unknown