code: def test_registry(self):
      @contract()
      def api1(module: nn.Module) -> nn.Module:
          return module
  
      @contract()
      def api2(module: nn.Module) -> nn.Module:
          return module
  
      model = ToyModel()
      model = api1(model)
      self.assertEqual(1, len(_get_registry(model)))
      self.assertTrue("api1" in _get_registry(model))
      model = api2(model)
      self.assertEqual(2, len(_get_registry(model)))
      self.assertTrue([_get_registry(model).keys()], ["api1", "api2"])
      self.assertEqual(None, _get_registry(model.seq1))
      self.assertEqual(None, _get_registry(model.seq2))
  
      with self.assertRaisesRegex(
          AssertionError, "api1 has already been applied"
      ):
          model = api1(model)
  
file_path: pytorch/test/distributed/_composable/test_contract.py
imports: from copy import deepcopy
  from typing import Tuple
  import torch
  import torch.nn
  from torch.distributed._composable import _get_registry, contract
  from torch.testing._internal.common_utils import run_tests, skipIfTorchDynamo, TestCase
label_desc: Use image node_id 4 for calling the TestContract obj's underlying member method code with example usage: obj.test_registry() and returns: module, module