# num_images = 5000, it_max = 500
ix1 = data['bounds']['it_max']
if num_images != -1:
ix1 = min(ix1, num_images) # should be `num_images = min(ix1, num_images)` ??
else:
num_images = ix1
for i in range(n - ix1):
predictions.pop() # error, pop from empty list
# .......
if num_images >= 0 and n >= num_images: # until `n == 5000`
break
https://github.com/ruotianluo/self-critical.pytorch/blob/58b4ea9f77a6b53a1d22138e6502fd4471e5b429/captioning/utils/eval_utils.py#L207