class_docstr: Pooling Op Superclass
class_docstr_tok: ["Pooling","Op","Superclass"]
code: def type_inference(self):
      ksize = self.kernel_sizes.val
      x_shape = self.x.shape
      D_in_rank = len(x_shape) - 2
  
      strides = (
          [1] * D_in_rank if self.strides is None else self.strides.val
      )
      pad_type = (
          "valid"
          if self.pad_type is None
          else self.pad_type.val.lower()
      )
      if pad_type not in ["valid", "same", "custom", "same_lower"]:
          raise ValueError(
              "Unrecognized value of pad_type : {}".format(pad_type)
          )
      pad = None if self.pad is None else self.pad.val
      D_in = x_shape[2:]  # spatial dimensions
  
      if self.ceil_mode.val:
          if D_in_rank > 2:
              raise ValueError(
                  "pool: ceil_mode only supported for 1D or 2D pool"
              )
          if pad_type == "same" and self.ceil_mode.val:
              raise ValueError(
                  "ceil_mode must be False when pad_type==same"
              )
          if pad is not None:
              for i in range(D_in_rank):
                  if pad[2 * i] != pad[2 * i + 1]:
                      raise ValueError(
                          "Padding must be symmetric if ceil_mode is True"
                      )
  
      # The same_lower padding is not supported in iOS15
      if (
          curr_opset_version() == _IOS15_TARGET
          and self.pad_type.val == "same_lower"
      ):
          msg = "iOS15 version of pooling layers do not support pad_type = `same_lower`"
          raise ValueError(msg)
  
      D_out_shape = spatial_dimensions_out_shape(
          pad_type=pad_type,
          input_shape=D_in,
          kernel_shape=ksize,
          strides=strides,
          custom_pad=pad,
          ceil_mode=self.ceil_mode.val,
      )
      ret_shape = list(x_shape[:2]) + D_out_shape
      return types.tensor(self.x.dtype, tuple(ret_shape))
  
file_path: coremltools/coremltools/converters/mil/mil/ops/defs/iOS15/pool.py
imports: from coremltools.converters.mil.mil import Operation, types
  from coremltools.converters.mil.mil.block import curr_opset_version
  from coremltools.converters.mil.mil.input_type import DefaultInputs, InputSpec, TensorInputType
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.ops.defs._utils import spatial_dimensions_out_shape
  from coremltools.converters.mil.mil.ops.defs.iOS15 import _IOS15_TARGET
label_desc: Use image node_id 2 for calling the Pooling obj's underlying member method code with example usage: obj.type_inference() and returns: types