code: def create_x3d_head(
      *,
      # Projection configs.
      dim_in: int,
      dim_inner: int,
      dim_out: int,
      num_classes: int,
      # Pooling configs.
      pool_act: Callable = nn.ReLU,
      pool_kernel_size: Tuple[int] = (13, 5, 5),
      # BN configs.
      norm: Callable = nn.BatchNorm3d,
      norm_eps: float = 1e-5,
      norm_momentum: float = 0.1,
      bn_lin5_on=False,
      # Dropout configs.
      dropout_rate: float = 0.5,
      # Activation configs.
      activation: Callable = nn.Softmax,
      # Output configs.
      output_with_global_average: bool = True,
  ) -> nn.Module:
      """
      Creates X3D head. This layer performs an projected pooling operation followed
      by an dropout, a fully-connected projection, an activation layer and a global
      spatiotemporal averaging.
  
      ::
  
                                       ProjectedPool
                                             ↓
                                          Dropout
                                             ↓
                                         Projection
                                             ↓
                                         Activation
                                             ↓
                                         Averaging
  
      Args:
          dim_in (int): input channel size of the X3D head.
          dim_inner (int): intermediate channel size of the X3D head.
          dim_out (int): output channel size of the X3D head.
          num_classes (int): the number of classes for the video dataset.
  
          pool_act (callable): a callable that constructs resnet pool activation
              layer such as nn.ReLU.
          pool_kernel_size (tuple): pooling kernel size(s) when not using adaptive
              pooling.
  
          norm (callable): a callable that constructs normalization layer, examples
              include nn.BatchNorm3d, None (not performing normalization).
          norm_eps (float): normalization epsilon.
          norm_momentum (float): normalization momentum.
          bn_lin5_on (bool): if True, perform normalization on the features
              before the classifier.
  
          dropout_rate (float): dropout rate.
  
          activation (callable): a callable that constructs resnet head activation
              layer, examples include: nn.ReLU, nn.Softmax, nn.Sigmoid, and None (not
              applying activation).
  
          output_with_global_average (bool): if True, perform global averaging on temporal
              and spatial dimensions and reshape output to batch_size x out_features.
  
      Returns:
          (nn.Module): X3D head layer.
      """
      pre_conv_module = nn.Conv3d(
          in_channels=dim_in,
          out_channels=dim_inner,
          kernel_size=(1, 1, 1),
          bias=False,
      )
  
      pre_norm_module = norm(
          num_features=dim_inner, eps=norm_eps, momentum=norm_momentum
      )
      pre_act_module = None if pool_act is None else pool_act()
  
      if pool_kernel_size is None:
          pool_module = nn.AdaptiveAvgPool3d((1, 1, 1))
      else:
          pool_module = nn.AvgPool3d(pool_kernel_size, stride=1)
  
      post_conv_module = nn.Conv3d(
          in_channels=dim_inner,
          out_channels=dim_out,
          kernel_size=(1, 1, 1),
          bias=False,
      )
  
      if bn_lin5_on:
          post_norm_module = norm(
              num_features=dim_out, eps=norm_eps, momentum=norm_momentum
          )
      else:
          post_norm_module = None
      post_act_module = None if pool_act is None else pool_act()
  
      projected_pool_module = ProjectedPool(
          pre_conv=pre_conv_module,
          pre_norm=pre_norm_module,
          pre_act=pre_act_module,
          pool=pool_module,
          post_conv=post_conv_module,
          post_norm=post_norm_module,
          post_act=post_act_module,
      )
  
      if activation is None:
          activation_module = None
      elif activation == nn.Softmax:
          activation_module = activation(dim=1)
      elif activation == nn.Sigmoid:
          activation_module = activation()
      else:
          raise NotImplementedError(
              "{} is not supported as an activation"
              "function.".format(activation)
          )
  
      if output_with_global_average:
          output_pool = nn.AdaptiveAvgPool3d(1)
      else:
          output_pool = None
  
      return ResNetBasicHead(
          proj=nn.Linear(dim_out, num_classes, bias=True),
          activation=activation_module,
          pool=projected_pool_module,
          dropout=nn.Dropout(dropout_rate)
          if dropout_rate > 0
          else None,
          output_pool=output_pool,
      )
  
imports: import math
  from typing import Callable, Tuple
  import numpy
  import torch
  import torch.nn
  from fvcore.nn.squeeze_excitation import SqueezeExcitation
  from pytorchvideo.layers.convolutions import Conv2plus1d
  from pytorchvideo.layers.swish import Swish
  from pytorchvideo.layers.utils import round_repeats, round_width, set_attributes
  from pytorchvideo.models.head import ResNetBasicHead
  from pytorchvideo.models.net import Net
  from pytorchvideo.models.resnet import BottleneckBlock, ResBlock, ResStage
  from pytorchvideo.models.stem import ResNetBasicStem
label_desc: Use image node_id 5 for calling a global function with example usage: create_x3d_head() and returns: ResNetBasicHead