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_function_in_forward(self):
      class NestedFunctionInForward(torch.nn.Module):
          def forward(self, x):
              return self.fun(x) + 10
  
          def fun(self, x):
              if isinstance(x, bool):
                  return 0
              elif isinstance(x, int):
                  return x + 1
              return 0
  
      make_global(NestedFunctionInForward)
      pdt_model = NestedFunctionInForward()
      inp: List[Tuple[Any, ...]] = [(-1,), (False,)]
      scripted_pdt_model = torch.jit.script(
          pdt_model, example_inputs={pdt_model: inp}
      )
      self.assertEqual(scripted_pdt_model(30), pdt_model(30))
      self.assertEqual(scripted_pdt_model(True), 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 4 for calling the TestPDT obj's underlying member method code with example usage: obj.test_nested_function_in_forward() and returns: unknown, int, int, unknown