# Sampler

Source: https://www.tensorplay.cn/docs/generated/tensorplay.utils.data.Sampler.html

# Sampler

class tensorplay.utils.data.Sampler[[source]](../_modules/tensorplay/utils/data.html#Sampler)

Base class for all Samplers.

Every Sampler subclass has to provide an __iter__() method, providing
a way to iterate over indices or lists of indices (batches) of dataset
elements, and may provide a __len__() method that returns the length
of the returned iterators.

Note

The __len__() method isn’t strictly required by
[DataLoader](tensorplay.utils.data.DataLoader.html#tensorplay.utils.data.DataLoader), but is expected in any
calculation involving the length of a DataLoader.
