分为disabled(dataloader的batch_size和batch_sampler参数都为None)和enabled两种状态,当为disabled时,简单的把数据转为tensor;当为enabled时,将dataset中__getitem()__返回的数据打包成batch,并维持原有的数据结构(It preserves the data structure, e.g., if each sample is a dictionary, it outputs a dictionary with the same set of keys but batched Tensors as values (or lists if the values can not be converted into Tensors). Same for list s, tuple s, namedtuple s, etc.)。
就是从样本列表中过来了一个batch的数据,经过映射函数,形成一个tensor。
collate_fn就是一个映射函数,输入是一个batch的样本,输出是一个tensor。有系统默认的,当然这个位置作为一个参数被暴露出来的意思就是你可以自己定义一个映射函数来代替它。