You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: topKLogits.m
    path of file: ./repos/transformer-models/+sampling
    
    the code of the file until where you have to start completion: function logits = topKLogits(logits, topK)
% topKLogits   Return the top K logits
%
%   logits = topKLogits(logits, k) will return a vector of logits where any
%   classes that are not in the top K largest values will be supressed.
%   Values are supressed by setting them to large negative values.
%
%   Inputs:
%       logits  - A numClasses-by-1 vector of logits.

    
function logits = topKLogits(logits, topK)
% topKLogits   Return the top K logits
%
%   logits = topKLogits(logits, k) will return a vector of logits where any
%   classes that are not in the top K largest values will be supressed.
%   Values are supressed by setting them to large negative values.
%
%   Inputs:
%       logits  - A numClasses-by-1 vector of logits.
%       k       - The number of values to 'keep'. Everything outside of the
%                 top K values will be supressed. Note for many typical use
%                 cases this parameter can have a big effect.
%
%   Outputs:
%       logits  - A numClasses-by-1 vector of logits.

if isa(logits, 'dlarray')
    extractedLogits = extractdata(logits);
else
    extractedLogits = logits;
end