def add_reduce(self, name, input_name, output_name, axis, mode, epsilon=1e-6):
        """
        Add a reduce layer. Applies the function specified by the parameter mode,
        along dimension(s) specified by the parameter axis.
        Refer to the ``ReduceLayerParams`` 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.

        axis: str
            dimensions along which the reduction operation is applied.
            Allowed values: 'CHW', 'HW', 'C', 'H', 'W'

        mode: str
            Reduction operation to be applied.
            Allowed values:
            'sum', 'avg', 'prod', 'logsum', 'sumsquare', 'L1', 'L2', 'max', 'min', 'argmax'.
            'argmax' is only supported with axis values 'C', 'H' and 'W'.

        epsilon: float
            number that is added to the input when 'logsum' function is applied.

        See Also
        --------
        add_activation
        """
        spec_layer = self._add_generic_layer(name, [input_name], [output_name])
        spec_layer_params = spec_layer.reduce
        spec_layer_params.epsilon = epsilon

        mode = mode.lower() if isinstance(mode, str) else mode
        if mode == "sum":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("SUM")
            )
        elif mode == "avg":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("AVG")
            )
        elif mode == "prod":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("PROD")
            )
        elif mode == "logsum":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("LOGSUM")
            )
        elif mode == "sumsquare":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("SUMSQUARE")
            )
        elif mode == "l1":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("L1")
            )
        elif mode == "l2":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("L2")
            )
        elif mode == "max":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("MAX")
            )
        elif mode == "min":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("MIN")
            )
        elif mode == "argmax":
            spec_layer_params.mode = (
                _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceOperation.Value("ARGMAX")
            )
        else:
            raise NotImplementedError("Unknown reduction operation %s." % mode)

        axis = axis.upper() if isinstance(axis, str) else axis
        if axis == "CHW":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceAxis.Value(
                "CHW"
            )
        elif axis == "HW":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceAxis.Value(
                "HW"
            )
        elif axis == "C":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceAxis.Value(
                "C"
            )
        elif axis == "H":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceAxis.Value(
                "H"
            )
        elif axis == "W":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.ReduceLayerParams.ReduceAxis.Value(
                "W"
            )
        else:
            raise NotImplementedError("Unknown reduction axis %s." % axis)
        return spec_layer

        Add a reduce layer. Applies the function specified by the parameter mode,
        along dimension(s) specified by the parameter axis.
        Refer to the ``ReduceLayerParams`` 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.

        axis: str
            dimensions along which the reduction operation is applied.
            Allowed values: 'CHW', 'HW', 'C', 'H', 'W'

        mode: str
            Reduction operation to be applied.
            Allowed values:
            'sum', 'avg', 'prod', 'logsum', 'sumsquare', 'L1', 'L2', 'max', 'min', 'argmax'.
            'argmax' is only supported with axis values 'C', 'H' and 'W'.

        epsilon: float
            number that is added to the input when 'logsum' function is applied.

        See Also
        --------
        add_activation
        
coremltools/models/neural_network/builder.py