code: def test_next_sets_last_failed_example(self) -> None:
      def fn(d: int) -> bool:
          if d == 3:
              raise ValueError("foo")
  
          return True
  
      pipeline = read_sequence([3, 4]).filter(fn).and_return()
  
      it = iter(pipeline)
  
      with pytest.raises(DataPipelineError):
          next(it)
  
      assert not pipeline.is_broken
  
      example = get_last_failed_example()
  
      assert isinstance(example, int)
  
      assert example == 3
  
      # We expect the error state to be cleared after a succesful operation.
      next(it)
  
      example = get_last_failed_example()
  
      assert example is None
  
imports: import pytest
  from fairseq2.data import DataPipelineError, get_last_failed_example, read_sequence
label_desc: Use image node_id 1 for calling the TestDataPipeline obj's underlying member method code with example usage: obj.test_next_sets_last_failed_example() and returns: True