The issue seems to be within the collate_fn. What is the collate_fn that you are passing into DataLoader? Within that function, is F defined?
collate_fn
F