code: def test_module_interface(self):
      @torch.jit.interface
      class OneTwoModule(nn.Module):
          def one(self, x: Tensor, y: Tensor) -> Tensor:
              pass
  
          def two(self, x: Tensor) -> Tensor:
              pass
  
          def forward(self, x: Tensor) -> Tensor:
              pass
  
      @torch.jit.interface
      class OneTwoClass:
          def one(self, x: Tensor, y: Tensor) -> Tensor:
              pass
  
          def two(self, x: Tensor) -> Tensor:
              pass
  
      class FooMod(nn.Module):
          def one(self, x: Tensor, y: Tensor) -> Tensor:
              return x + y
  
          def two(self, x: Tensor) -> Tensor:
              return 2 * x
  
          def forward(self, x: Tensor) -> Tensor:
              return self.one(self.two(x), x)
  
      class BarMod(nn.Module):
          def one(self, x: Tensor, y: Tensor) -> Tensor:
              return x * y
  
          def two(self, x: Tensor) -> Tensor:
              return 2 / x
  
          def forward(self, x: Tensor) -> Tensor:
              return self.two(self.one(x, x))
  
          @torch.jit.export
          def forward2(self, x: Tensor) -> Tensor:
              return self.two(self.one(x, x)) + 1
  
      make_global(OneTwoModule, OneTwoClass)
  
      def use_module_interface(
          mod_list: List[OneTwoModule], x: torch.Tensor
      ):
          return mod_list[0].forward(x) + mod_list[1].forward(x)
  
      def use_class_interface(
          mod_list: List[OneTwoClass], x: Tensor
      ) -> Tensor:
          return mod_list[0].two(x) + mod_list[1].one(x, x)
  
      scripted_foo_mod = torch.jit.script(FooMod())
      scripted_bar_mod = torch.jit.script(BarMod())
      self.checkScript(
          use_module_interface,
          (
              [scripted_foo_mod, scripted_bar_mod],
              torch.rand(3, 4),
          ),
      )
      self.checkScript(
          use_class_interface,
          (
              [scripted_foo_mod, scripted_bar_mod],
              torch.rand(3, 4),
          ),
      )
  
      def call_module_interface_on_other_method(
          mod_interface: OneTwoModule, x: Tensor
      ) -> Tensor:
          return mod_interface.forward2(x)
  
      # ensure error out when we call the module on the method other than the interface specified.
      with self.assertRaisesRegexWithHighlight(
          RuntimeError,
          "object has no attribute or method",
          "mod_interface.forward2",
      ):
          self.checkScript(
              call_module_interface_on_other_method,
              (
                  scripted_bar_mod,
                  torch.rand(3, 4),
              ),
          )
  
imports: from typing import List, Any
  import torch
  import torch.nn
  import os
  import sys
  from torch import Tensor
  from torch.testing._internal.jit_utils import JitTestCase, make_global
label_desc: Use image node_id 2 for calling the TestModuleInterface obj's underlying member method code with example usage: obj.test_module_interface() and returns: unknown, unknown, mod_interface, unknown, unknown, self, unknown, unknown, self, unknown