def add_topk(
        self, name, input_names, output_names, k=0, axis=0, use_bottom_k=False
    ):
        """
        Add a topk layer to the model that returns top or bottom k values and
        the corresponding indices of the input tensor along a given axis.
        Refer to the ``TopKLayerParams`` 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. It must be of length 1 or 2.
            The optional second input corresponds to value of K.
        output_names: list of str
            The output blob names of this layer. First and second correspond to
            values and indices, respectively.
        k: int, optional
            number of values/indices to be computed along the axis.
            Need not be given of there are two inputs, default: 0.
        axis: int, optional
            axis along which the topk values/indices are computed.
            negative indexing is supported, default: 0
        use_bottom_k: bool, optional
            if true, bottom k values are computed instead, default: false.
        """

        spec_layer = self._add_generic_layer(name, input_names, output_names)
        spec_layer_params = spec_layer.topK
        spec_layer_params.axis = axis
        spec_layer_params.K = k
        spec_layer_params.useBottomK = use_bottom_k
        return spec_layer

        Add a topk layer to the model that returns top or bottom k values and
        the corresponding indices of the input tensor along a given axis.
        Refer to the ``TopKLayerParams`` 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. It must be of length 1 or 2.
            The optional second input corresponds to value of K.
        output_names: list of str
            The output blob names of this layer. First and second correspond to
            values and indices, respectively.
        k: int, optional
            number of values/indices to be computed along the axis.
            Need not be given of there are two inputs, default: 0.
        axis: int, optional
            axis along which the topk values/indices are computed.
            negative indexing is supported, default: 0
        use_bottom_k: bool, optional
            if true, bottom k values are computed instead, default: false.
        
coremltools/models/neural_network/builder.py