Almost same as the above answers though, functools.partial enabeles you to specify arguments other than batch like this
from functools import partial


def my_collate_fn(batch, a, b):
    ...

DataLoader(..., collate_fn=partial(my_collate_fn, a=foo, b=bar))