class_docstr: Lightweight multi-scale linear attention.
class_docstr_tok: ["Lightweight","multi-scale","linear","attention","."]
code: def __init__(
      self,
      in_channels: int,
      out_channels: int,
      heads: int or None = None,
      heads_ratio: float = 1.0,
      dim=8,
      use_bias=False,
      norm=(None, "bn2d"),
      act_func=(None, None),
      kernel_func="relu",
      scales: tuple[int, ...] = (5,),
      eps=1.0e-15,
  ):
      super().__init__()
      self.eps = eps
      heads = heads or int(in_channels // dim * heads_ratio)
  
      total_dim = heads * dim
  
      use_bias = val2tuple(use_bias, 2)
      norm = val2tuple(norm, 2)
      act_func = val2tuple(act_func, 2)
  
      self.dim = dim
      self.qkv = ConvLayer(
          in_channels,
          3 * total_dim,
          1,
          use_bias=use_bias[0],
          norm=norm[0],
          act_func=act_func[0],
      )
      self.aggreg = nn.ModuleList(
          [
              nn.Sequential(
                  nn.Conv2d(
                      3 * total_dim,
                      3 * total_dim,
                      scale,
                      padding=get_same_padding(scale),
                      groups=3 * total_dim,
                      bias=use_bias[0],
                  ),
                  nn.Conv2d(
                      3 * total_dim,
                      3 * total_dim,
                      1,
                      groups=3 * heads,
                      bias=use_bias[0],
                  ),
              )
              for scale in scales
          ]
      )
      self.kernel_func = build_act(kernel_func, inplace=False)
  
      self.proj = ConvLayer(
          total_dim * (1 + len(scales)),
          out_channels,
          1,
          use_bias=use_bias[1],
          norm=norm[1],
          act_func=act_func[1],
      )
  
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.cuda.amp import autocast
  from kornia.contrib.models.efficient_vit.nn.act import build_act
  from kornia.contrib.models.efficient_vit.nn.norm import build_norm
  from kornia.contrib.models.efficient_vit.utils import get_same_padding, val2tuple
label_desc: Use image node_id 1 to create a new LiteMLA object from inherited base classes: nn with example: obj = LiteMLA(in_channels, out_channels, heads, heads_ratio, dim, use_bias, norm, act_func, kernel_func, scales, eps)