code: def create_nonlocal(
      *,
      # Nonlocal configs.
      dim_in: int,
      dim_inner: int,
      pool_size: Optional[Tuple[int]] = (1, 1, 1),
      instantiation: str = "softmax",
      # Norm configs.
      norm: Optional[Callable] = nn.BatchNorm3d,
      norm_eps: float = 1e-5,
      norm_momentum: float = 0.1,
  ):
      """
      Builds Non-local Neural Networks as a generic family of building
      blocks for capturing long-range dependencies. Non-local Network
      computes the response at a position as a weighted sum of the
      features at all positions. This building block can be plugged into
      many computer vision architectures.
      More details in the paper: https://arxiv.org/pdf/1711.07971
      Args:
          dim_in (int): number of dimension for the input.
          dim_inner (int): number of dimension inside of the Non-local block.
          pool_size (tuple[int]): the kernel size of spatial temporal pooling,
              temporal pool kernel size, spatial pool kernel size, spatial pool kernel
              size in order. By default pool_size is None, then there would be no pooling
              used.
          instantiation (string): supports two different instantiation method:
              "dot_product": normalizing correlation matrix with L2.
              "softmax": normalizing correlation matrix with Softmax.
          norm (nn.Module): nn.Module for the normalization layer. The default is
              nn.BatchNorm3d.
          norm_eps (float): normalization epsilon.
          norm_momentum (float): normalization momentum.
      """
      if pool_size is None:
          pool_size = (1, 1, 1)
      assert isinstance(pool_size, Iterable)
  
      if norm is None:
          norm_model = None
      else:
          norm_model = norm(
              num_features=dim_in, eps=norm_eps, momentum=norm_momentum
          )
  
      if any(size > 1 for size in pool_size):
          pool_model = nn.MaxPool3d(
              kernel_size=pool_size, stride=pool_size, padding=[0, 0, 0]
          )
      else:
          pool_model = None
  
      return NonLocal(
          conv_theta=nn.Conv3d(
              dim_in, dim_inner, kernel_size=1, stride=1, padding=0
          ),
          conv_phi=nn.Conv3d(
              dim_in, dim_inner, kernel_size=1, stride=1, padding=0
          ),
          conv_g=nn.Conv3d(
              dim_in, dim_inner, kernel_size=1, stride=1, padding=0
          ),
          conv_out=nn.Conv3d(
              dim_inner, dim_in, kernel_size=1, stride=1, padding=0
          ),
          pool=pool_model,
          norm=norm_model,
          instantiation=instantiation,
      )
  
file_path: pytorchvideo/pytorchvideo/layers/nonlocal_net.py
imports: from typing import Callable, Iterable, Optional, Tuple
  import torch
  import torch.nn
  from pytorchvideo.layers.utils import set_attributes
label_desc: Use image node_id 1 for calling a global function with example usage: create_nonlocal() and returns: NonLocal