class_docstr: Applies padding to input (if needed) so that input can get fully covered
  by filter you specified. It support two modes "same" and "corner". The
  "same" mode is same with "SAME" padding mode in TensorFlow, pad zero around
  input. The "corner"  mode would pad zero to bottom right.
  
  Args:
      kernel_size (int | tuple): Size of the kernel:
      stride (int | tuple): Stride of the filter. Default: 1:
      dilation (int | tuple): Spacing between kernel elements.
          Default: 1
      padding (str): Support "same" and "corner", "corner" mode
          would pad zero to bottom right, and "same" mode would
          pad zero around input. Default: "corner".
  Example:
      >>> kernel_size = 16
      >>> stride = 16
      >>> dilation = 1
      >>> input = torch.rand(1, 1, 15, 17)
      >>> adap_pad = AdaptivePadding(
      >>>     kernel_size=kernel_size,
      >>>     stride=stride,
      >>>     dilation=dilation,
      >>>     padding="corner")
      >>> out = adap_pad(input)
      >>> assert (out.shape[2], out.shape[3]) == (16, 32)
      >>> input = torch.rand(1, 1, 16, 17)
      >>> out = adap_pad(input)
      >>> assert (out.shape[2], out.shape[3]) == (16, 32)
class_docstr_tok: ["Applies","padding","to","input","(","if","needed",")","so","that","input","can","get","fully","covered","by","filter","you","specified",".","It","support","two","modes","``","same","''","and","``","corner","''",".","The","''","same","''","mode","is","same","with","``","SAME","''","padding","mode","in","TensorFlow",",","pad","zero","around","input",".","The","``","corner","''","mode","would","pad","zero","to","bottom","right",".","Args",":","kernel_size","(","int","|","tuple",")",":","Size","of","the","kernel",":","stride","(","int","|","tuple",")",":","Stride","of","the","filter",".","Default",":","1",":","dilation","(","int","|","tuple",")",":","Spacing","between","kernel","elements",".","Default",":","1","padding","(","str",")",":","Support","``","same","''","and","``","corner","''",",","``","corner","''","mode","would","pad","zero","to","bottom","right",",","and","``","same","''","mode","would","pad","zero","around","input",".","Default",":","``","corner","''",".","Example",":",">",">",">","kernel_size","=","16",">",">",">","stride","=","16",">",">",">","dilation","=","1",">",">",">","input","=","torch.rand","(","1",",","1",",","15",",","17",")",">",">",">","adap_pad","=","AdaptivePadding","(",">",">",">","kernel_size=kernel_size",",",">",">",">","stride=stride",",",">",">",">","dilation=dilation",",",">",">",">","padding=","''","corner","''",")",">",">",">","out","=","adap_pad","(","input",")",">",">",">","assert","(","out.shape","[","2","]",",","out.shape","[","3","]",")","==","(","16",",","32",")",">",">",">","input","=","torch.rand","(","1",",","1",",","16",",","17",")",">",">",">","out","=","adap_pad","(","input",")",">",">",">","assert","(","out.shape","[","2","]",",","out.shape","[","3","]",")","==","(","16",",","32",")"]
code: def forward(self, x):
      pad_h, pad_w = self.get_pad_shape(x.size()[-2:])
      if pad_h > 0 or pad_w > 0:
          if self.padding == "corner":
              x = F.pad(x, [0, pad_w, 0, pad_h])
          elif self.padding == "same":
              x = F.pad(
                  x,
                  [
                      pad_w // 2,
                      pad_w - pad_w // 2,
                      pad_h // 2,
                      pad_h - pad_h // 2,
                  ],
              )
      return x
  
imports: import math
  import warnings
  from typing import Optional, Sequence, Tuple, Union
  import torch
  import torch.nn.functional
  from mmcv.cnn import Linear, build_activation_layer, build_conv_layer, build_norm_layer
  from mmcv.cnn.bricks.drop import Dropout
  from mmengine.model import BaseModule, ModuleList
  from mmengine.utils import to_2tuple
  from torch import Tensor, nn
  from mmdet.registry import MODELS
  from mmdet.utils import OptConfigType, OptMultiConfig
label_desc: Use image node_id 3 for calling the AdaptivePadding obj's underlying member method code with example usage: obj.forward(x) and returns: x