class_docstr: Implements the Multi-Aspect Global Context Attention, as described in
  <https://arxiv.org/pdf/1910.02562.pdf>`_.
  
  Args:
  ----
      inplanes: input channels
      headers: number of headers to split channels
      attn_scale: if True, re-scale attention to counteract the variance distibutions
      ratio: bottleneck ratio
      **kwargs
class_docstr_tok: ["Implements","the","Multi-Aspect","Global","Context","Attention",",","as","described","in","<","https",":","\/\/arxiv.org\/pdf\/1910.02562.pdf",">","`","_",".","Args",":","--","--","inplanes",":","input","channels","headers",":","number","of","headers","to","split","channels","attn_scale",":","if","True",",","re-scale","attention","to","counteract","the","variance","distibutions","ratio",":","bottleneck","ratio","*","*","kwargs"]
code: def __init__(
      self,
      inplanes: int,
      headers: int = 8,
      attn_scale: bool = False,
      ratio: float = 0.0625,  # bottleneck ratio of 1/16 as described in paper
      cfg: Optional[Dict[str, Any]] = None,
  ) -> None:
      super().__init__()
  
      self.headers = headers
      self.inplanes = inplanes
      self.attn_scale = attn_scale
      self.planes = int(inplanes * ratio)
  
      self.single_header_inplanes = int(inplanes / headers)
  
      self.conv_mask = nn.Conv2d(
          self.single_header_inplanes, 1, kernel_size=1
      )
      self.softmax = nn.Softmax(dim=1)
  
      self.transform = nn.Sequential(
          nn.Conv2d(self.inplanes, self.planes, kernel_size=1),
          nn.LayerNorm([self.planes, 1, 1]),
          nn.ReLU(inplace=True),
          nn.Conv2d(self.planes, self.inplanes, kernel_size=1),
      )
  
file_path: doctr/doctr/models/classification/magc_resnet/pytorch.py
imports: import math
  from copy import deepcopy
  from functools import partial
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  from torch import nn
  from doctr.datasets import VOCABS
  from ...utils.pytorch import load_pretrained_params
  from ..resnet.pytorch import ResNet
label_desc: Use image node_id 1 to create a new MAGC object from inherited base classes: nn with example: obj = MAGC(inplanes, headers, attn_scale, ratio, cfg)