def add_slice(
        self, name, input_name, output_name, axis, start_index=0, end_index=-1, stride=1
    ):
        """
        Add a slice layer. Equivalent to to numpy slice [start_index:end_index:stride],
        start_index is included, while end_index is exclusive.
        Refer to the ``SliceLayerParams`` 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
            axis along which input is sliced.
            allowed values: 'channel', 'height', 'width'
        start_index: int
            must be non-negative.
        end_index: int
            negative indexing is supported.
        stride: int
            must be positive.

        See Also
        --------
        add_permute, add_reshape
        """
        spec_layer = self._add_generic_layer(name, [input_name], [output_name])
        spec_layer_params = spec_layer.slice

        # Set the parameters
        if start_index < 0:
            raise ValueError(
                "Invalid start_index value %d. Must be non-negative." % start_index
            )
        if stride < 1:
            raise ValueError("Invalid stride value %d. Must be positive." % stride)

        spec_layer_params.startIndex = start_index
        spec_layer_params.endIndex = end_index
        spec_layer_params.stride = stride

        axis = axis.lower() if isinstance(axis, str) else axis
        if axis == "channel":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.SliceLayerParams.SliceAxis.Value(
                "CHANNEL_AXIS"
            )
        elif axis == "height":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.SliceLayerParams.SliceAxis.Value(
                "HEIGHT_AXIS"
            )
        elif axis == "width":
            spec_layer_params.axis = _proto.NeuralNetwork_pb2.SliceLayerParams.SliceAxis.Value(
                "WIDTH_AXIS"
            )
        else:
            raise NotImplementedError("Unsupported Slice axis %s " % axis)
        return spec_layer

        Add a slice layer. Equivalent to to numpy slice [start_index:end_index:stride],
        start_index is included, while end_index is exclusive.
        Refer to the ``SliceLayerParams`` 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
            axis along which input is sliced.
            allowed values: 'channel', 'height', 'width'
        start_index: int
            must be non-negative.
        end_index: int
            negative indexing is supported.
        stride: int
            must be positive.

        See Also
        --------
        add_permute, add_reshape
        
coremltools/models/neural_network/builder.py