code: def create_resnet_with_roi_head(
      *,
      # Input clip configs.
      input_channel: int = 3,
      # Model configs.
      model_depth: int = 50,
      model_num_class: int = 80,
      dropout_rate: float = 0.5,
      # Normalization configs.
      norm: Callable = nn.BatchNorm3d,
      # Activation configs.
      activation: Callable = nn.ReLU,
      # Stem configs.
      stem_dim_out: int = 64,
      stem_conv_kernel_size: Tuple[int] = (1, 7, 7),
      stem_conv_stride: Tuple[int] = (1, 2, 2),
      stem_pool: Callable = nn.MaxPool3d,
      stem_pool_kernel_size: Tuple[int] = (1, 3, 3),
      stem_pool_stride: Tuple[int] = (1, 2, 2),
      stem: Callable = create_res_basic_stem,
      # Stage configs.
      stage1_pool: Callable = None,
      stage1_pool_kernel_size: Tuple[int] = (2, 1, 1),
      stage_conv_a_kernel_size: Union[Tuple[int], Tuple[Tuple[int]]] = (
          (1, 1, 1),
          (1, 1, 1),
          (3, 1, 1),
          (3, 1, 1),
      ),
      stage_conv_b_kernel_size: Union[Tuple[int], Tuple[Tuple[int]]] = (
          (1, 3, 3),
          (1, 3, 3),
          (1, 3, 3),
          (1, 3, 3),
      ),
      stage_conv_b_num_groups: Tuple[int] = (1, 1, 1, 1),
      stage_conv_b_dilation: Union[Tuple[int], Tuple[Tuple[int]]] = (
          (1, 1, 1),
          (1, 1, 1),
          (1, 1, 1),
          (1, 2, 2),
      ),
      stage_spatial_h_stride: Tuple[int] = (1, 2, 2, 1),
      stage_spatial_w_stride: Tuple[int] = (1, 2, 2, 1),
      stage_temporal_stride: Tuple[int] = (1, 1, 1, 1),
      bottleneck: Union[
          Tuple[Callable], Callable
      ] = create_bottleneck_block,
      # Head configs.
      head: Callable = create_res_roi_pooling_head,
      head_pool: Callable = nn.AvgPool3d,
      head_pool_kernel_size: Tuple[int] = (4, 1, 1),
      head_output_size: Tuple[int] = (1, 1, 1),
      head_activation: Callable = nn.Sigmoid,
      head_output_with_global_average: bool = False,
      head_spatial_resolution: Tuple[int] = (7, 7),
      head_spatial_scale: float = 1.0 / 16.0,
      head_sampling_ratio: int = 0,
  ) -> nn.Module:
      """
      Build ResNet style models for video detection. ResNet has three parts:
      Stem, Stages and Head. Stem is the first Convolution layer (Conv1) with an
      optional pooling layer. Stages are grouped residual blocks. There are usually
      multiple stages and each stage may include multiple residual blocks. Head
      may include pooling, dropout, a fully-connected layer and global spatial
      temporal averaging. The three parts are assembled in the following order:
  
      ::
  
                              Input Clip    Input Bounding Boxes
                                ↓                       ↓
                              Stem                      ↓
                                ↓                       ↓
                              Stage 1                   ↓
                                ↓                       ↓
                                .                       ↓
                                .                       ↓
                                .                       ↓
                                ↓                       ↓
                              Stage N                   ↓
                                ↓--------> Head <-------↓
  
      Args:
  
          input_channel (int): number of channels for the input video clip.
  
          model_depth (int): the depth of the resnet. Options include: 50, 101, 152.
          model_num_class (int): the number of classes for the video dataset.
          dropout_rate (float): dropout rate.
  
  
          norm (callable): a callable that constructs normalization layer.
  
          activation (callable): a callable that constructs activation layer.
  
          stem_dim_out (int): output channel size to stem.
          stem_conv_kernel_size (tuple): convolutional kernel size(s) of stem.
          stem_conv_stride (tuple): convolutional stride size(s) of stem.
          stem_pool (callable): a callable that constructs resnet head pooling layer.
          stem_pool_kernel_size (tuple): pooling kernel size(s).
          stem_pool_stride (tuple): pooling stride size(s).
          stem (callable): a callable that constructs stem layer.
              Examples include: create_res_video_stem.
  
          stage_conv_a_kernel_size (tuple): convolutional kernel size(s) for conv_a.
          stage_conv_b_kernel_size (tuple): convolutional kernel size(s) for conv_b.
          stage_conv_b_num_groups (tuple): number of groups for groupwise convolution
              for conv_b. 1 for ResNet, and larger than 1 for ResNeXt.
          stage_conv_b_dilation (tuple): dilation for 3D convolution for conv_b.
          stage_spatial_h_stride (tuple): the spatial height stride for each stage.
          stage_spatial_w_stride (tuple): the spatial width stride for each stage.
          stage_temporal_stride (tuple): the temporal stride for each stage.
          bottleneck (callable): a callable that constructs bottleneck block layer.
              Examples include: create_bottleneck_block.
  
          head (callable): a callable that constructs the detection head which can
              take in the additional input of bounding boxes.
              Ex: create_res_roi_pooling_head
          head_pool (callable): a callable that constructs resnet head pooling layer.
          head_pool_kernel_size (tuple): the pooling kernel size.
          head_output_size (tuple): the size of output tensor for head.
          head_activation (callable): a callable that constructs activation layer.
          head_output_with_global_average (bool): if True, perform global averaging on
              the head output.
          head_spatial_resolution (tuple): h, w sizes of the RoI interpolation.
          head_spatial_scale (float): scale the input boxes by this number.
          head_sampling_ratio (int): number of inputs samples to take for each output
                  sample interpolation. 0 to take samples densely.
  
      Returns:
          (nn.Module): basic resnet.
      """
  
      model = create_resnet(
          # Input clip configs.
          input_channel=input_channel,
          # Model configs.
          model_depth=model_depth,
          model_num_class=model_num_class,
          dropout_rate=dropout_rate,
          # Normalization configs.
          norm=norm,
          # Activation configs.
          activation=activation,
          # Stem configs.
          stem_dim_out=stem_dim_out,
          stem_conv_kernel_size=stem_conv_kernel_size,
          stem_conv_stride=stem_conv_stride,
          stem_pool=stem_pool,
          stem_pool_kernel_size=stem_pool_kernel_size,
          stem_pool_stride=stem_pool_stride,
          # Stage configs.
          stage1_pool=stage1_pool,
          stage_conv_a_kernel_size=stage_conv_a_kernel_size,
          stage_conv_b_kernel_size=stage_conv_b_kernel_size,
          stage_conv_b_num_groups=stage_conv_b_num_groups,
          stage_conv_b_dilation=stage_conv_b_dilation,
          stage_spatial_h_stride=stage_spatial_h_stride,
          stage_spatial_w_stride=stage_spatial_w_stride,
          stage_temporal_stride=stage_temporal_stride,
          bottleneck=bottleneck,
          # Head configs.
          head=None,
      )
      head = head(
          in_features=stem_dim_out
          * 2 ** (len(_MODEL_STAGE_DEPTH[model_depth]) + 1),
          out_features=model_num_class,
          pool=head_pool,
          output_size=head_output_size,
          pool_kernel_size=head_pool_kernel_size,
          dropout_rate=dropout_rate,
          activation=head_activation,
          output_with_global_average=head_output_with_global_average,
          resolution=head_spatial_resolution,
          spatial_scale=head_spatial_scale,
          sampling_ratio=head_sampling_ratio,
      )
      return DetectionBBoxNetwork(model, head)
  
imports: from typing import Callable, List, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from pytorchvideo.layers.utils import set_attributes
  from pytorchvideo.models.head import create_res_basic_head, create_res_roi_pooling_head
  from pytorchvideo.models.net import DetectionBBoxNetwork, Net
  from pytorchvideo.models.stem import create_acoustic_res_basic_stem, create_res_basic_stem
label_desc: Use image node_id 7 for calling a global function with example usage: create_resnet_with_roi_head() and returns: DetectionBBoxNetwork