class_docstr: This function implements 2d pooling of the input tensor.
  
  Arguments
  ---------
  pool_type : str
      It is the type of pooling function to use ('avg','max').
  pool_axis : tuple
      It is a list containing the axis that will be considered
      during pooling.
  kernel_size : int
      It is the kernel size that defines the pooling dimension.
      For instance, kernel size=3,3 performs a 2D Pooling with a 3x3 kernel.
  stride : int
      It is the stride size.
  padding : int
      It is the number of padding elements to apply.
  dilation : int
      Controls the dilation factor of pooling.
  ceil_mode : bool
      When True, will use ceil instead of floor to compute the output shape.
  
  Example
  -------
  >>> pool = Pooling2d('max',(5,3))
  >>> inputs = torch.rand(10, 15, 12)
  >>> output=pool(inputs)
  >>> output.shape
  torch.Size([10, 3, 4])
docstr: Performs 2d pooling to the input tensor.
  
  Arguments
  ---------
  x : torch.Tensor
      It represents a tensor for a mini-batch.
docstr_tok: ["Performs","2d","pooling","to","the","input","tensor",".","Arguments","--","--","--","--","-","x",":","torch.Tensor","It","represents","a","tensor","for","a","mini-batch","."]
code: def forward(self, x):
      """Performs 2d pooling to the input tensor.
  
      Arguments
      ---------
      x : torch.Tensor
          It represents a tensor for a mini-batch.
      """
      # Add extra two dimension at the last two, and then swap the pool_axis to them
      # Example: pool_axis=[1,2]
      # [a,b,c,d] => [a,b,c,d,1,1]
      # [a,b,c,d,1,1] => [a,1,c,d,b,1]
      # [a,1,c,d,b,1] => [a,1,1,d,b,c]
      # [a,1,1,d,b,c] => [a,d,b,c]
      x = (
          x.unsqueeze(-1)
          .unsqueeze(-1)
          .transpose(-2, self.pool_axis[0])
          .transpose(-1, self.pool_axis[1])
          .squeeze(self.pool_axis[1])
          .squeeze(self.pool_axis[0])
      )
  
      # Apply pooling
      x = self.pool_layer(x)
  
      # Swap back the pool_axis from the last two dimension
      # Example: pool_axis=[1,2]
      # [a,d,b,c] => [a,1,d,b,c]
      # [a,1,d,b,c] => [a,1,1,d,b,c]
      # [a,1,1,d,b,c] => [a,b,1,d,1,c]
      # [a,b,1,d,1,c] => [a,b,c,d,1,1]
      # [a,b,c,d,1,1] => [a,b,c,d]
      x = (
          x.unsqueeze(self.pool_axis[0])
          .unsqueeze(self.pool_axis[1])
          .transpose(-2, self.pool_axis[0])
          .transpose(-1, self.pool_axis[1])
          .squeeze(-1)
          .squeeze(-1)
      )
  
      return x
  
imports: import torch
  import logging
  import torch.nn
  import torch.nn.functional
label_desc: Use image node_id 2 for calling the Pooling2d obj's underlying member method code with example usage: obj.forward(x) and returns: x