class_docstr: Global Average Pooling neck.
  
  Note that we use `view` to remove extra channel after pooling. We do not
  use `squeeze` as it will also remove the batch dimension when the tensor
  has a batch dimension of size 1, which can lead to unexpected errors.
code: def forward(self, inputs):
      if isinstance(inputs, tuple):
          outs = tuple([self.gap(x) for x in inputs])
          outs = tuple(
              [
                  out.view(
                      x.size(0), torch.tensor(out.size()[1:]).prod()
                  )
                  for out, x in zip(outs, inputs)
              ]
          )
      elif isinstance(inputs, torch.Tensor):
          outs = self.gap(inputs)
          outs = outs.view(
              inputs.size(0), torch.tensor(outs.size()[1:]).prod()
          )
      else:
          raise TypeError("neck inputs should be tuple or torch.tensor")
      return outs
  
file_path: mmdetection/mmdet/models/reid/gap.py
imports: import torch
  import torch.nn
  from mmengine.model import BaseModule
  from mmdet.registry import MODELS
label_desc: Use image node_id 2 for calling the GlobalAveragePooling obj's underlying member method code with example usage: obj.forward(inputs) and returns: outs