code: def test_malformed_chunks(all_parsers, nrows):
      data = """ignore
  A,B,C
  skip
  1,2,3
  3,5,10 # comment
  1,2,3,4,5
  2,3,4
  """
      parser = all_parsers
  
      if parser.engine == "pyarrow":
          msg = "The 'iterator' option is not supported with the 'pyarrow' engine"
          with pytest.raises(ValueError, match=msg):
              parser.read_csv(
                  StringIO(data),
                  header=1,
                  comment="#",
                  iterator=True,
                  chunksize=1,
                  skiprows=[2],
              )
          return
  
      msg = "Expected 3 fields in line 6, saw 5"
      with parser.read_csv(
          StringIO(data),
          header=1,
          comment="#",
          iterator=True,
          chunksize=1,
          skiprows=[2],
      ) as reader:
          with pytest.raises(ParserError, match=msg):
              reader.read(nrows)
  
imports: import codecs
  import csv
  from io import StringIO
  import os
  from pathlib import Path
  import numpy
  import pytest
  from pandas.compat import PY311
  from pandas.errors import EmptyDataError, ParserError, ParserWarning
  from pandas import DataFrame
  import pandas._testing
label_desc: Use image node_id 4 for calling a global function with example usage: test_malformed_chunks(all_parsers, nrows) without return types