code: def test_unsupported_return_list_with_module_class(self):
      class Foo(torch.nn.Module):
          pass
  
      class MyTestModuleForListWithModuleClass(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.foo = Foo()
  
          def forward(self):
              my_list: List[Foo] = [self.foo]
              return my_list
  
      script_module = torch.jit.script(
          MyTestModuleForListWithModuleClass()
      )
      with self.assertRaisesRegex(
          RuntimeError,
          r"^Returning a list or dictionary with pytorch class type "
          r"is not supported in mobile module "
          r"\(List\[Foo\] or Dict\[int\, Foo\] for class Foo\(torch\.nn\.Module\)\)\. "
          r"Workaround\: instead of using pytorch class as their element type\, "
          r"use a combination of list\, dictionary\, and single types\.$",
      ):
          script_module._save_to_buffer_for_lite_interpreter()
  
imports: import torch
  import torch.utils.bundled_inputs
  import io
  from tempfile import TemporaryFileName
  from typing import Dict, List
  import inspect
  from torch.testing import FileCheck
  from torch.jit.mobile import _load_for_lite_interpreter, _export_operator_list
  from torch.testing._internal.common_utils import TestCase, run_tests
  from torch.testing._internal.common_quantization import AnnotatedSingleLayerLinearModel, TwoLayerLinearModel, AnnotatedNestedModel
  from torch.testing._internal.common_quantization import QuantizationLiteTestCase
label_desc: Use image node_id 8 for calling the TestLiteScriptModule obj's underlying member method code with example usage: obj.test_unsupported_return_list_with_module_class() and returns: my_list