class_docstr: Tests just-in-time cpp extensions.
  Don't confuse this with the PyTorch JIT (aka TorchScript).
code: def test_cpp_frontend_module_python_inter_op(self):
      extension = torch.utils.cpp_extension.load(
          name="cpp_frontend_extension",
          sources="cpp_extensions/cpp_frontend_extension.cpp",
          verbose=True,
      )
  
      # Create a torch.nn.Module which uses the C++ module as a submodule.
      class M(torch.nn.Module):
          def __init__(self):
              super().__init__()
              self.x = torch.nn.Parameter(torch.tensor(1.0))
              self.net = extension.Net(3, 5)
  
          def forward(self, input):
              return self.net.forward(input) + self.x
  
      net = extension.Net(5, 2)
      net.double()
      net.to(torch.get_default_dtype())
      self.assertEqual(str(net), "Net")
  
      # Further embed the torch.nn.Module into a Sequential, and also add the
      # C++ module as an element of the Sequential.
      sequential = torch.nn.Sequential(
          M(), torch.nn.Tanh(), net, torch.nn.Sigmoid()
      )
  
      input = torch.randn(2, 3)
      # Try calling the module!
      output = sequential.forward(input)
      # The call operator is bound to forward too.
      self.assertEqual(output, sequential(input))
      self.assertEqual(list(output.shape), [2, 2])
  
      # Do changes on the module hierarchy.
      old_dtype = torch.get_default_dtype()
      sequential.to(torch.float64)
      sequential.to(torch.float32)
      sequential.to(old_dtype)
      self.assertEqual(sequential[2].parameters()[0].dtype, old_dtype)
  
      # Make sure we can access these methods recursively.
      self.assertEqual(
          len(list(sequential.parameters())),
          len(net.parameters()) * 2 + 1,
      )
      self.assertEqual(
          len(list(sequential.named_parameters())),
          len(net.named_parameters()) * 2 + 1,
      )
      self.assertEqual(
          len(list(sequential.buffers())), len(net.buffers()) * 2
      )
      self.assertEqual(len(list(sequential.modules())), 8)
  
      # Test clone()
      net2 = net.clone()
      self.assertEqual(len(net.parameters()), len(net2.parameters()))
      self.assertEqual(len(net.buffers()), len(net2.buffers()))
      self.assertEqual(len(net.modules()), len(net2.modules()))
  
      # Try differentiating through the whole module.
      for parameter in net.parameters():
          self.assertIsNone(parameter.grad)
      output.sum().backward()
      for parameter in net.parameters():
          self.assertFalse(parameter.grad is None)
          self.assertGreater(parameter.grad.sum(), 0)
  
      # Try calling zero_grad()
      net.zero_grad()
      for p in net.parameters():
          assert (
              p.grad is None
          ), "zero_grad defaults to setting grads to None"
  
      # Test train(), eval(), training (a property)
      self.assertTrue(net.training)
      net.eval()
      self.assertFalse(net.training)
      net.train()
      self.assertTrue(net.training)
      net.eval()
  
      # Try calling the additional methods we registered.
      biased_input = torch.randn(4, 5)
      output_before = net.forward(biased_input)
      bias = net.get_bias().clone()
      self.assertEqual(list(bias.shape), [2])
      net.set_bias(bias + 1)
      self.assertEqual(net.get_bias(), bias + 1)
      output_after = net.forward(biased_input)
  
      self.assertNotEqual(output_before, output_after)
  
      # Try accessing parameters
      self.assertEqual(len(net.parameters()), 2)
      np = net.named_parameters()
      self.assertEqual(len(np), 2)
      self.assertIn("fc.weight", np)
      self.assertIn("fc.bias", np)
  
      self.assertEqual(len(net.buffers()), 1)
      nb = net.named_buffers()
      self.assertEqual(len(nb), 1)
      self.assertIn("buf", nb)
      self.assertEqual(nb[0][1], torch.eye(5))
  
imports: import os
  import shutil
  import sys
  import unittest
  import warnings
  import re
  import tempfile
  import subprocess
  import glob
  import torch.testing._internal.common_utils
  from torch.testing._internal.common_cuda import TEST_CUDNN, TEST_CUDA
  import torch
  import torch.backends.cudnn
  import torch.utils.cpp_extension
  from torch.utils.cpp_extension import CUDA_HOME, ROCM_HOME
  from torch.testing._internal.common_utils import gradcheck
  import torch.multiprocessing
  from torch.utils.cpp_extension import _TORCH_PATH, remove_extension_h_precompiler_headers, get_cxx_compiler, check_compiler_is_gcc
label_desc: Use image node_id 21 for calling the TestCppExtensionJIT obj's underlying member method code with example usage: obj.test_cpp_frontend_module_python_inter_op() and returns: unknown