def METHOD_NAME(self):
    if self.drop_last and len(self.dataset) % self.num_replicas != 0:
        # Split to nearest available length that is evenly divisible.
        # This is to ensure each rank receives the same amount of data when
        # using this Sampler.
        self.num_samples = math.ceil(
            (len(self.dataset) - self.num_replicas) / self.num_replicas
        )
    else:
        self.num_samples = math.ceil(len(self.dataset) / self.num_replicas)