class_docstr: 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.pdf
class_docstr_tok: ["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.pdf"]
code: def _construct_nonlocal(
      self, zero_init_final_conv, zero_init_final_norm, norm_module
  ):
      # Three convolution heads: theta, phi, and g.
      self.conv_theta = nn.Conv3d(
          self.dim, self.dim_inner, kernel_size=1, stride=1, padding=0
      )
      self.conv_phi = nn.Conv3d(
          self.dim, self.dim_inner, kernel_size=1, stride=1, padding=0
      )
      self.conv_g = nn.Conv3d(
          self.dim, self.dim_inner, kernel_size=1, stride=1, padding=0
      )
  
      # Final convolution output.
      self.conv_out = nn.Conv3d(
          self.dim_inner, self.dim, kernel_size=1, stride=1, padding=0
      )
      # Zero initializing the final convolution output.
      self.conv_out.zero_init = zero_init_final_conv
  
      # TODO: change the name to `norm`
      self.bn = norm_module(
          num_features=self.dim,
          eps=self.norm_eps,
          momentum=self.norm_momentum,
      )
      # Zero initializing the final bn.
      self.bn.transform_final_bn = zero_init_final_norm
  
      # Optional to add the spatial-temporal pooling.
      if self.use_pool:
          self.pool = nn.MaxPool3d(
              kernel_size=self.pool_size,
              stride=self.pool_size,
              padding=[0, 0, 0],
          )
  
imports: import torch
  import torch.nn
label_desc: Use image node_id 2 for calling the Nonlocal obj's underlying member method code with example usage: obj._construct_nonlocal(zero_init_final_conv, zero_init_final_norm, norm_module) without return types