code: def test_op_saves_and_restores_its_state(self, window: int) -> None:
      seq = list(range(5000))
  
      pipeline1 = read_sequence(seq).shuffle(window).and_return()
      pipeline2 = read_sequence(seq).shuffle(window).and_return()
  
      with tmp_rng_seed(CPU, seed=1234):
          expected_output1 = list(islice(pipeline1, 4000))
  
      with tmp_rng_seed(CPU, seed=5678):
          expected_output2 = list(islice(pipeline1, 1000))
  
      with tmp_rng_seed(CPU, seed=1234):
          assert list(islice(pipeline2, 4000)) == expected_output1
  
      state_dict = pipeline2.state_dict()
  
      with tmp_rng_seed(CPU, seed=5678):
          assert list(islice(pipeline2, 1000)) == expected_output2
  
      pipeline2.load_state_dict(state_dict)
  
      with tmp_rng_seed(CPU, seed=5678):
          assert list(islice(pipeline2, 1000)) == expected_output2
  
      pipeline2.reset()
      pipeline2.load_state_dict(state_dict)
  
      with tmp_rng_seed(CPU, seed=5678):
          assert list(islice(pipeline2, 1000)) == expected_output2
  
      state_dict = pipeline2.state_dict()
  
      with pytest.raises(StopIteration):
          next(iter(pipeline2))
  
      pipeline2.reset()
  
      pipeline2.load_state_dict(state_dict)
  
      with pytest.raises(StopIteration):
          next(iter(pipeline2))
  
file_path: fairseq2/tests/unit/data/data_pipeline/test_shuffle.py
imports: from itertools import islice
  import pytest
  from fairseq2.data import read_sequence
  from fairseq2.typing import CPU
  from tests.common import tmp_rng_seed
label_desc: Use image node_id 2 for calling the TestShuffleOp obj's underlying member method code with example usage: obj.test_op_saves_and_restores_its_state(window) without return types