class_docstr: K-max global pooling block
  
  https://arxiv.org/abs/1911.07344
code: def forward(self, x: Tensor):  # skipcq: PYL-W0221
      input = x.view(x.size(0), x.size(1), -1)
      kmax = input.topk(k=self.k, dim=2)[0]
      kmax = (kmax * self.weights).mean(dim=2)
      if not self.flatten:
          kmax = kmax.view(kmax.size(0), kmax.size(1), 1, 1)
      return kmax
  
imports: from typing import Union, Dict
  import torch
  import torch.nn.functional
  from torch.nn.modules.module import _IncompatibleKeys
  from torch import Tensor, nn
label_desc: Use image node_id 2 for calling the GlobalKMaxPool2d obj's underlying member method code with example usage: obj.forward(x) and returns: kmax