I’m not sure why the targets would have a different length, since also one-hot encoded targets should contain values for all classes (0 for inactive, 1 for active classes).
Could you explain the targets and their shape a bit more?