code: def test_state_dict_check_length(self):
      dataset = TorchNormalDataset(num_of_data=100)
      sampler = RandomSampler(dataset, shuffle=False)
      states = sampler.state_dict()
  
      new_ds = TorchNormalDataset(num_of_data=10)
      with pytest.raises(AssertionError):
          new_sampler = RandomSampler(new_ds)
          new_sampler.load_state_dict(states)
  
      new_ds = TorchNormalDataset(num_of_data=100)
      new_sampler = RandomSampler(new_ds)
      new_sampler.load_state_dict(states)
  
imports: import numpy
  import pytest
  from functools import partial
  from itertools import chain
  from copy import deepcopy
  from fastNLP.core.samplers.reproducible_sampler import RandomSampler, SortedSampler, SequentialSampler
  from tests.helpers.datasets.torch_data import TorchNormalDataset
label_desc: Use image node_id 4 for calling the TestRandomSamplerYh obj's underlying member method code with example usage: obj.test_state_dict_check_length() without return types