tens = SimpleQueue()

NameError: name ‘SimpleQueue’ is not defined

You also need to import SimpleQueue.
from torch.multiprocessing import Process, **Queue**, Lock
 → 
from torch.multiprocessing import Process, **SimpleQueue**, Lock

print("in consumer process, get %d tensors, still %d left in the queue" % (ten_count, tens.qsize()))

AttributeError: ‘SimpleQueue’ object has no attribute ‘qsize’

I guess you can just avoid qsize in the print method. If you still want to print it out, then you can create a separate counter instead.