Solved by mMagmer in post #4 
              
              
                That was my guess. 
Based on the code, I think you’re implementing a BatchSampler not a sampler. 
I don’t know how you can fix your code,