code: def write_test_to_test_class(
      unit_test_class,
      test_params_dict,
      test_instance_class,
      parity_table,
      devices,
  ):
      assert not is_torch_nn_functional_test(test_params_dict)
  
      module_name = compute_module_name(test_params_dict)
  
      assert hasattr(torch.nn, module_name), (
          f"`torch.nn` doesn't have module `{module_name}`. "
          "If you are adding a new test, please set `fullname` using format `ModuleName_desc` "
          f"or set `module_name` using format `ModuleName` in the module test dict:\n{pprint.pformat(test_params_dict)}"
      )
  
      module_full_name = "torch::nn::" + module_name
  
      assert module_full_name in parity_table["torch::nn"], (
          f"Please add `{module_full_name}` entry to `torch::nn` section of `test/cpp_api_parity/parity-tracker.md`. "
          f"(Discovered while processing\n{pprint.pformat(test_params_dict)}.)"
      )
  
      for device in devices:
          test_params = process_test_params_for_module(
              test_params_dict=test_params_dict,
              device=device,
              test_instance_class=test_instance_class,
          )
          try_remove_folder(test_params.cpp_tmp_folder)
          unit_test_name = (
              f"test_torch_nn_{test_params.module_variant_name}"
          )
          unit_test_class.module_test_params_map[
              unit_test_name
          ] = test_params
  
          def test_fn(self):
              test_forward_backward(
                  unit_test_class=self,
                  test_params=unit_test_class.module_test_params_map[
                      self._testMethodName
                  ],
              )
  
          test_fn = decorate_test_fn(
              test_fn=test_fn,
              test_cuda=test_params_dict.get("test_cuda", True),
              has_impl_parity=parity_table["torch::nn"][
                  module_full_name
              ][0]
              and test_params_dict.get("has_parity", True),
              device=device,
          )
  
          add_test(unit_test_class, unit_test_name, test_fn)
  
file_path: pytorch/test/cpp_api_parity/module_impl_check.py
imports: import tempfile
  from string import Template
  import types
  import pprint
  import os
  import torch
  from cpp_api_parity.utils import TorchNNModuleTestParams, TORCH_NN_COMMON_TEST_HARNESS, compile_cpp_code_inline, set_python_tensors_requires_grad, move_python_tensors_to_device, add_test, compute_cpp_args_construction_stmts_and_forward_arg_symbols, serialize_arg_dict_as_script_module, compute_arg_dict, decorate_test_fn, compute_temp_file_path, generate_error_msg, is_torch_nn_functional_test, try_remove_folder
  from cpp_api_parity.sample_module import SAMPLE_MODULE_CPP_SOURCE
label_desc: Use image node_id 5 for calling a global function with example usage: write_test_to_test_class(unit_test_class, test_params_dict, test_instance_class, parity_table, devices) without return types