def add_slice_dynamic(
        self,
        name,
        input_names,
        output_name,
        end_ids=None,
        strides=None,
        begin_masks=None,
        end_masks=None,
        squeeze_masks=None,
    ):
        """
        Add a slice_dynamic layer to the model that extracts a slice of size
        ``(end - begin) / stride`` from the given input tensor.
        Refer to the ``SliceDynamicLayerParams`` message in the specification (NeuralNetwork.proto) for more details.

        Parameters
        ----------
        name: str
            The name of this layer.
        input_names: list of str
            The input blob names of this layer.
        output_name: str
            The output blob name of this layer.
        end_ids: list of int or tuple of int, optional
            End offsets for slice layer, default: [1].
        strides: list of int or tuple of int, optional
            Strides for slice layer, default: [1].
        begin_masks: list of bool, optional
            Boolean masks for begin offsets, default: [false].
        end_masks: list of bool, optional
            Boolean masks for end offsets, default: [false].
        squeeze_masks: list of bool, optional
            Boolean masks for squeezing axis, default: [false].

        See Also
        --------
        add_slice_static
        """

        if not end_ids:
            end_ids = [1 for _ in range(5)]
        if not strides:
            strides = [1 for _ in range(5)]
        if not begin_masks:
            begin_masks = [False for _ in range(5)]
        if not end_masks:
            end_masks = [False for _ in range(5)]
        if not squeeze_masks:
            squeeze_masks = [False for _ in range(5)]

        spec_layer = self._add_generic_layer(name, input_names, [output_name])
        spec_layer_params = spec_layer.sliceDynamic

        spec_layer_params.endIds.extend(end_ids)
        spec_layer_params.strides.extend(strides)
        spec_layer_params.beginMasks.extend(begin_masks)
        spec_layer_params.endMasks.extend(end_masks)
        if not any(squeeze_masks):
            return spec_layer

        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_params.squeezeMasks.extend(squeeze_masks)

        return spec_layer

        Add a slice_dynamic layer to the model that extracts a slice of size
        ``(end - begin) / stride`` from the given input tensor.
        Refer to the ``SliceDynamicLayerParams`` message in the specification (NeuralNetwork.proto) for more details.

        Parameters
        ----------
        name: str
            The name of this layer.
        input_names: list of str
            The input blob names of this layer.
        output_name: str
            The output blob name of this layer.
        end_ids: list of int or tuple of int, optional
            End offsets for slice layer, default: [1].
        strides: list of int or tuple of int, optional
            Strides for slice layer, default: [1].
        begin_masks: list of bool, optional
            Boolean masks for begin offsets, default: [false].
        end_masks: list of bool, optional
            Boolean masks for end offsets, default: [false].
        squeeze_masks: list of bool, optional
            Boolean masks for squeezing axis, default: [false].

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