It seems that the problem occurs in pos_weight = positive_weights.
From the docs


pos_weight  ( Tensor  1 ,  optional ) – a weight of positive examples. Must be a vector with length equal to the number of classes.

But why does it consider 5 as the number of classes?