class_docstr: This class implements global pooling with linear projection
code: def __init__(
      self, opts, in_dim: int, out_dim: int, *args, **kwargs
  ) -> None:
      super().__init__(opts, *args, **kwargs)
  
      scale = in_dim**-0.5
      self.use_identity = (
          getattr(
              opts,
              "model.image_projection_head.global_pool_nchw2nc.identity_if_same_size",
          )
          and in_dim == out_dim
      )
      self.pool = GlobalPool(pool_type="mean", keep_dim=False)
      if not self.use_identity:
          self.proj = nn.Parameter(
              scale * torch.randn(size=(in_dim, out_dim))
          )
      else:
          if is_master(opts):
              logger.log(
                  f"Using identity projection for GlobalPool2D given input/out size = {in_dim}."
              )
      self.in_dim = in_dim
      self.out_dim = out_dim
  
      self.feature_normalization = not getattr(
          opts,
          "model.image_projection_head.global_pool_nchw2nc.no_feature_normalization",
      )
  
      self.reset_parameters()
  
file_path: ml-cvnets/cvnets/image_projection_layers/global_pool_2d.py
imports: import argparse
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from cvnets.image_projection_layers import IMAGE_PROJECTION_HEAD_REGISTRY, BaseImageProjectionHead
  from cvnets.layers import GlobalPool
  from utils import logger
  from utils.ddp_utils import is_master
label_desc: Use image node_id 1 to create a new GlobalPool2D object from inherited base classes: BaseImageProjectionHead with example: obj = GlobalPool2D(opts, in_dim, out_dim)