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_class_with_args_as_profiled_types(self):
      class ClassWithArgs:
          def __init__(self, a: bool):
              self.a = a
  
          def fn(self, b):
              if self.a:
                  return b
              else:
                  return -1
  
      def test_model_with_args(a, m):
          assert not isinstance(a, bool)
          return m.fn(a)
  
      make_global(ClassWithArgs, test_model_with_args)
  
      user_class = ClassWithArgs(False)
      scripted_fn = torch.jit.script(
          test_model_with_args,
          example_inputs=[
              (
                  10,
                  user_class,
              ),
              (
                  10.9,
                  user_class,
              ),
          ],
      )
      self.assertEqual(
          scripted_fn(
              100,
              ClassWithArgs(True),
          ),
          test_model_with_args(100, ClassWithArgs(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 15 for calling the TestPDT obj's underlying member method code with example usage: obj.test_class_with_args_as_profiled_types() and returns: m, b, unknown