class_docstr: Non-local block
  
  Parameters
  ----------
  in_channels : int.
      Input channels of each block.
  nonlocal_type : str.
      Types of design for non-local block.
  dim : int, default 3.
      2D or 3D non-local block.
  embed_dim : int.
      Intermediate number of channels.
  sub_sample : bool.
      Whether to downsample the feature map to save computation.
  use_bn : bool.
      Whether to use batch normalization layer inside a non-local block.
  norm_layer : object
      Normalization layer used (default: :class:`mxnet.gluon.nn.BatchNorm`)
      Can be :class:`mxnet.gluon.nn.BatchNorm` or :class:`mxnet.gluon.contrib.nn.SyncBatchNorm`.
  norm_kwargs : dict
      Additional `norm_layer` arguments, for example `num_devices=4`
      for :class:`mxnet.gluon.contrib.nn.SyncBatchNorm`.
  ctx : Context, default CPU.
      The context in which to load the pretrained weights.
code: def hybrid_forward(self, F, x):
      if self.embed:
          theta = self.theta(x)
          if self.sub_sample:
              phi = self.sub_phi(x)
              g = self.sub_g(x)
          else:
              phi = self.phi(x)
              g = self.g(x)
      else:
          theta = x
          phi = x
          g = x
  
      if self.nonlocal_type == "gaussian":
          # reshape [BxCxTxHxW] to [BxCxTHW]
          theta = F.reshape(theta, (0, 0, -1))
          phi = F.reshape(phi, (0, 0, -1))
          g = F.reshape(g, (0, 0, -1))
          # Direct transpose is slow, merge it into `batch_dot` operation.
          # theta_phi = nd.batch_dot(F.transpose(theta, axes=(0, 2, 1)), phi)
          theta_phi = F.batch_dot(theta, phi, transpose_a=True)
          # Normalizing the affinity tensor theta_phi before softmax.
          theta_phi = theta_phi * (self.embed_dim**-0.5)
          attn = F.softmax(theta_phi, axis=2)
      elif self.non_local_type == "concat":
          raise NotImplementedError
      elif self.non_local_type == "dot":
          raise NotImplementedError
      else:
          raise NotImplementedError
  
      y = F.batch_dot(g, attn, transpose_b=True)
      y = F.reshape_like(
          y, x, lhs_begin=2, lhs_end=None, rhs_begin=2, rhs_end=None
      )
  
      if self.use_bn:
          z = self.W_bn(y) + x
      else:
          z = self.W(y) + x
      return z
  
file_path: gluon-cv/gluoncv/model_zoo/action_recognition/non_local.py
imports: from mxnet.gluon.block import HybridBlock
  from mxnet import init
  from mxnet.gluon import nn
  from mxnet.gluon.nn import BatchNorm
label_desc: Use image node_id 2 for calling the NonLocal obj's underlying member method code with example usage: obj.hybrid_forward(F, x) and returns: z