class_index is assigned to the current class index in the for loop over all classes.
Your code (testset.targets == class_index) wouldn’t use the model predictions, but just all targets and the current selected class target.
The function will plot a PR curve for each class.
EDIT: Issue might be related to this post 2.