def add_stack(self, name, input_names, output_name, axis=0):
        """
        Add a stack layer to the model that performs stack operation on a list of
        tensors into one rank+1 tensor on the given axis.
        Refer to the ``StackLayerParams`` 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.
        axis: int, optional
            The axis to perform stack operation, default: 0.
        """

        spec_layer = self._add_generic_layer(name, input_names, [output_name])
        spec_layer.stack.axis = axis
        self.rank_dict[output_name] = self._get_rank(input_names[0]) + 1
        return spec_layer

        Add a stack layer to the model that performs stack operation on a list of
        tensors into one rank+1 tensor on the given axis.
        Refer to the ``StackLayerParams`` 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.
        axis: int, optional
            The axis to perform stack operation, default: 0.
        
coremltools/models/neural_network/builder.py