class_docstr: Selectable global pooling layer with dynamic input kernel size
      
class_docstr_tok: ["Selectable","global","pooling","layer","with","dynamic","input","kernel","size"]
code: def __init__(
      self,
      output_size: _int_tuple_2_t = 1,
      pool_type: str = "fast",
      flatten: bool = False,
      input_fmt: str = "NCHW",
  ):
      super(SelectAdaptivePool2d, self).__init__()
      assert input_fmt in ("NCHW", "NHWC")
      self.pool_type = (
          pool_type or ""
      )  # convert other falsy values to empty string for consistent TS typing
      if not pool_type:
          self.pool = nn.Identity()  # pass through
          self.flatten = nn.Flatten(1) if flatten else nn.Identity()
      elif pool_type.startswith("fast") or input_fmt != "NCHW":
          assert (
              output_size == 1
          ), "Fast pooling and non NCHW input formats require output_size == 1."
          if pool_type.endswith("catavgmax"):
              self.pool = FastAdaptiveCatAvgMaxPool(
                  flatten, input_fmt=input_fmt
              )
          elif pool_type.endswith("avgmax"):
              self.pool = FastAdaptiveAvgMaxPool(
                  flatten, input_fmt=input_fmt
              )
          elif pool_type.endswith("max"):
              self.pool = FastAdaptiveMaxPool(
                  flatten, input_fmt=input_fmt
              )
          else:
              self.pool = FastAdaptiveAvgPool(
                  flatten, input_fmt=input_fmt
              )
          self.flatten = nn.Identity()
      else:
          assert input_fmt == "NCHW"
          if pool_type == "avgmax":
              self.pool = AdaptiveAvgMaxPool2d(output_size)
          elif pool_type == "catavgmax":
              self.pool = AdaptiveCatAvgMaxPool2d(output_size)
          elif pool_type == "max":
              self.pool = nn.AdaptiveMaxPool2d(output_size)
          else:
              self.pool = nn.AdaptiveAvgPool2d(output_size)
          self.flatten = nn.Flatten(1) if flatten else nn.Identity()
  
imports: from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from .format import get_spatial_dim, get_channel_dim
label_desc: Use image node_id 1 to create a new SelectAdaptivePool2d object from inherited base classes: nn with example: obj = SelectAdaptivePool2d(output_size, pool_type, flatten, input_fmt)