def add_pooling3d(
        self,
        name,
        input_name,
        output_name,
        pooling_type,
        kernel_depth,
        kernel_height,
        kernel_width,
        stride_depth,
        stride_height,
        stride_width,
        padding_mode="valid",
        custom_padding_front=0,
        custom_padding_back=0,
        custom_padding_top=0,
        custom_padding_bottom=0,
        custom_padding_left=0,
        custom_padding_right=0,
        average_pooling_count_excludes_padding=False,
    ):
        """
        Add a pooling layer to the model that performs spatial pooling across three dimensions.
        Refer to the ``Pooling3DLayerParams`` message in the specification
        (NeuralNetwork.proto) for more details.

        Parameters
        ----------
        name: str
            The name of this layer.
        input_name: str
            The input blob name of this layer.
        output_name: str
            The output blob name of this layer.
        pooling_type: str
            Type of pooling performed. Can either be ``'MAX'`` OR ``'AVERAGE'``.
        kernel_depth: int
            Depth of the pooling region.
        kernel_height: int
            Height of pooling region.
        kernel_width: int
            Width of pooling region.
        stride_depth: int
            Stride along the depth direction
        stride_height: int
            Stride along the height direction.
        stride_width: int
            Stride along the width direction.
        padding_mode: str
            Option for the padding type and output blob shape.
            Can be ``'VALID'``, ``'SAME'``, or ``'CUSTOM'``.
        custom_padding_front: int
            Padding before the input in the depth direction.
        custom_padding_back: int
            Padding after the input in the depth direction.
        custom_padding_top: int
            Padding before the input in the height direction.
        custom_padding_bottom: int
            Padding after the input in the height direction.
        custom_padding_left: int
            Padding before the input in the width direction.
        custom_padding_right: int
            Padding after the input in the width direction.
        average_pooling_count_excludes_padding: boolean
            If true, exclude zeros from padding in average pooling.
            Can only be true for ``AVERAGE`` padding.

        See Also
        --------
        add_pooling, add_global_pooling3d
        """
        if self.spec and (
            not self.spec.specificationVersion
            or self.spec.specificationVersion < _SPECIFICATION_VERSION_IOS_14
        ):
            self.spec.specificationVersion = _SPECIFICATION_VERSION_IOS_14
        spec_layer = self._add_generic_layer(name, [input_name], [output_name])
        spec_layer_params = spec_layer.pooling3d

        spec_layer_params.type = _proto.NeuralNetwork_pb2.Pooling3DLayerParams.PoolingType3D.Value(
            pooling_type.upper()
        )

        spec_layer_params.kernelDepth = kernel_depth
        spec_layer_params.kernelHeight = kernel_height
        spec_layer_params.kernelWidth = kernel_width

        spec_layer_params.strideDepth = stride_depth
        spec_layer_params.strideHeight = stride_height
        spec_layer_params.strideWidth = stride_width

        supported_padding_modes = {"CUSTOM", "VALID", "SAME"}
        if padding_mode.upper() not in supported_padding_modes:
            raise ValueError(
                "Unsupported padding mode: %s.  Must be one of %s"
                % (padding_mode, supported_padding_modes)
            )
        if padding_mode.upper() == "CUSTOM":
            spec_layer_params.customPaddingFront = custom_padding_front
            spec_layer_params.customPaddingBack = custom_padding_back
            spec_layer_params.customPaddingTop = custom_padding_top
            spec_layer_params.customPaddingBottom = custom_padding_bottom
            spec_layer_params.customPaddingLeft = custom_padding_left
            spec_layer_params.customPaddingRight = custom_padding_right
        spec_layer_params.paddingType = (
            _proto.NeuralNetwork_pb2.Pooling3DLayerParams.Pooling3DPaddingType.Value(
                padding_mode.upper()
            )
        )

        spec_layer_params.countExcludePadding = average_pooling_count_excludes_padding

        return spec_layer

        Add a pooling layer to the model that performs spatial pooling across three dimensions.
        Refer to the ``Pooling3DLayerParams`` message in the specification
        (NeuralNetwork.proto) for more details.

        Parameters
        ----------
        name: str
            The name of this layer.
        input_name: str
            The input blob name of this layer.
        output_name: str
            The output blob name of this layer.
        pooling_type: str
            Type of pooling performed. Can either be ``'MAX'`` OR ``'AVERAGE'``.
        kernel_depth: int
            Depth of the pooling region.
        kernel_height: int
            Height of pooling region.
        kernel_width: int
            Width of pooling region.
        stride_depth: int
            Stride along the depth direction
        stride_height: int
            Stride along the height direction.
        stride_width: int
            Stride along the width direction.
        padding_mode: str
            Option for the padding type and output blob shape.
            Can be ``'VALID'``, ``'SAME'``, or ``'CUSTOM'``.
        custom_padding_front: int
            Padding before the input in the depth direction.
        custom_padding_back: int
            Padding after the input in the depth direction.
        custom_padding_top: int
            Padding before the input in the height direction.
        custom_padding_bottom: int
            Padding after the input in the height direction.
        custom_padding_left: int
            Padding before the input in the width direction.
        custom_padding_right: int
            Padding after the input in the width direction.
        average_pooling_count_excludes_padding: boolean
            If true, exclude zeros from padding in average pooling.
            Can only be true for ``AVERAGE`` padding.

        See Also
        --------
        add_pooling, add_global_pooling3d
        
coremltools/models/neural_network/builder.py