K is a placeholder for the number of additional dimensions your output and target have.
In a simple classification use case, K would be 0, which means:


output = [batch_size, nb_classes], target = [batch_size]


In the case of K=1, e.g. for a temporal signal, where each sample belongs to a specific class:


output = [batch_size, nb_classes, seq_len], target = [batch_size, seq_len]


For a segmentation use case:


output = [batch_size, nb_classes, height width], target = [batch_size, height width]


…
As you can see, K simply indicates the dimensionality of your current use case and how the output and target should look like.