class_docstr: Spatial NL block for image classification.
  
  This was adapted from https://github.com/BA-Transform/BAT-Image-Classification
  Their NonLocal impl inspired by https://github.com/facebookresearch/video-nonlocal-net.
class_docstr_tok: ["Spatial","NL","block","for","image","classification",".","This","was","adapted","from","https",":","\/\/github.com\/BA-Transform\/BAT-Image-Classification","Their","NonLocal","impl","inspired","by","https",":","\/\/github.com\/facebookresearch\/video-nonlocal-net","."]
code: def __init__(
      self,
      in_channels,
      use_scale=True,
      rd_ratio=1 / 8,
      rd_channels=None,
      rd_divisor=8,
      **kwargs,
  ):
      super(NonLocalAttn, self).__init__()
      if rd_channels is None:
          rd_channels = make_divisible(
              in_channels * rd_ratio, divisor=rd_divisor
          )
      self.scale = in_channels**-0.5 if use_scale else 1.0
      self.t = nn.Conv2d(
          in_channels, rd_channels, kernel_size=1, stride=1, bias=True
      )
      self.p = nn.Conv2d(
          in_channels, rd_channels, kernel_size=1, stride=1, bias=True
      )
      self.g = nn.Conv2d(
          in_channels, rd_channels, kernel_size=1, stride=1, bias=True
      )
      self.z = nn.Conv2d(
          rd_channels, in_channels, kernel_size=1, stride=1, bias=True
      )
      self.norm = nn.BatchNorm2d(in_channels)
      self.reset_parameters()
  
file_path: pytorch-image-models/timm/layers/non_local_attn.py
imports: import torch
  from torch import nn
  from torch.nn import functional
  from .conv_bn_act import ConvNormAct
  from .helpers import make_divisible
  from .trace_utils import _assert
label_desc: Use image node_id 1 to create a new NonLocalAttn object from inherited base classes: nn with example: obj = NonLocalAttn(in_channels, use_scale, rd_ratio, rd_channels, rd_divisor)