code: def test_optional_type_promotion(self):
      @torch.jit.script
      class Leaf:
          def __init__(self):
              self.x = 1
  
      # should not throw
      @torch.jit.script  # noqa: B903
      class Tree:  # noqa: B903
          def __init__(self):
              self.child = torch.jit.annotate(Optional[Leaf], None)
  
          def add_child(self, child: Leaf) -> None:
              self.child = child
  
imports: import io
  import os
  import sys
  import unittest
  import torch
  import torch.nn
  from torch.testing import FileCheck
  from typing import Any
  from torch.testing._internal.jit_utils import JitTestCase, make_global
  import torch.testing._internal.jit_utils
  from torch.testing._internal.common_utils import IS_SANDCASTLE, skipIfTorchDynamo
  from typing import List, Tuple, Iterable, Optional, Dict
label_desc: Use image node_id 28 for calling the TestClassType obj's underlying member method code with example usage: obj.test_optional_type_promotion() without return types