class_docstr: 随机顺序的 Sampler 。
  
  :param dataset: 实现了 __len__ 方法的数据容器
  :param shuffle: 是否在每次 iterate 的时候打乱顺序
  :param seed: 随机数种子
  :param kwargs: fastNLP 内部使用的参数
class_docstr_tok: ["\u968f\u673a\u987a\u5e8f\u7684","Sampler","\u3002",":","param","dataset",":","\u5b9e\u73b0\u4e86","__len__","\u65b9\u6cd5\u7684\u6570\u636e\u5bb9\u5668",":","param","shuffle",":","\u662f\u5426\u5728\u6bcf\u6b21","iterate","\u7684\u65f6\u5019\u6253\u4e71\u987a\u5e8f",":","param","seed",":","\u968f\u673a\u6570\u79cd\u5b50",":","param","kwargs",":","fastNLP","\u5185\u90e8\u4f7f\u7528\u7684\u53c2\u6570"]
code: def load_state_dict(self, states: Dict):
      # 如果 self.during_iter 是 True，那么 num_consumed_samples 一定是 0；
      assert self.during_iter is False, (
          "Cannot call load_state_dict() when it is "
          "during an unfinished iteration."
      )
  
      assert states["sampler_type"] == self.__class__.__name__, (
          f"The sampler type in checkpoint is {states['sampler_type']},"
          f"we cannot use {self.__class__.__name__} to load it."
      )
  
      length = states["length"]
      assert length == self.num_samples, (
          "The number of samples is different between the checkpoint "
          f"record({length}) and current dataset({self.num_samples})."
      )
      self.seed = states["seed"]
      self.epoch = states["epoch"]
      self.num_consumed_samples = states["num_consumed_samples"]
      if (
          self.num_consumed_samples >= length
      ):  # 如果保存的时候已经到达了最后一个sample了，则直接将结果重置为0
          self.num_consumed_samples = 0
      if self.shuffle != states["shuffle"]:
          logger.info(
              f"The shuffle from the checkpoint is {states['shuffle']}, while set as {self.shuffle}, "
              f"we use shuffle={states['shuffle']}"
          )
      self.shuffle = states["shuffle"]
  
imports: from typing import Dict, List, Union, Sequence
  import math
  import numpy
  from fastNLP.core.log import logger
  from fastNLP.core.dataset import DataSet
label_desc: Use image node_id 6 for calling the RandomSampler obj's underlying member method code with example usage: obj.load_state_dict(states) without return types