docstr: Test complex ResNetRoIHead.
docstr_tok: ["Test","complex","ResNetRoIHead","."]
code: def test_build_complex_head(self):
      """
      Test complex ResNetRoIHead.
      """
      # ROI layer configs
      resolution = (10, 15)
      spatial_scale = 1.0 / 5.0
      sampling_ratio = 0
      roi_layer = RoIAlign(
          resolution,
          spatial_scale=spatial_scale,
          sampling_ratio=sampling_ratio,
      )
  
      for input_dim, output_dim in itertools.product(
          (4, 8), (4, 8, 16)
      ):
          model = ResNetRoIHead(
              proj=nn.Linear(input_dim, output_dim),
              activation=nn.Softmax(),
              pool=nn.AdaptiveAvgPool3d(1),
              pool_spatial=nn.MaxPool2d(resolution, stride=1),
              roi_layer=roi_layer,
              dropout=nn.Dropout(0.5),
              output_pool=nn.AdaptiveAvgPool3d(1),
          )
  
          # Test forwarding.
          for input_tensor, bboxes in TestRoIHeadHelper._get_inputs(
              input_dim=input_dim
          ):
              if input_tensor.shape[1] != input_dim:
                  with self.assertRaises(Exception):
                      output_tensor = model(input_tensor, bboxes)
                  continue
              output_tensor = model(input_tensor, bboxes)
  
              bboxes_shape = bboxes.shape
              output_shape = output_tensor.shape
              output_shape_gt = (bboxes_shape[0], output_dim)
              self.assertEqual(
                  output_shape,
                  output_shape_gt,
                  "Output shape {} is different from expected shape {}".format(
                      output_shape, output_shape_gt
                  ),
              )
  
imports: import itertools
  import unittest
  import numpy
  import torch
  from pytorchvideo.models.head import create_res_basic_head, create_res_roi_pooling_head, create_vit_basic_head, ResNetBasicHead, ResNetRoIHead, SequencePool
  from torch import nn
  from torchvision.ops import RoIAlign
label_desc: Use image node_id 5 for calling the TestRoIHeadHelper obj's underlying member method code with example usage: obj.test_build_complex_head() without return types