code: def read_csv(
      path, encoding="utf-8", headers=None, sep=",", dropna=True
  ):
      r"""
      Construct a generator to read csv items.
  
      :param path: file path
      :param encoding: file's encoding, default: utf-8
      :param headers: file's headers, if None, make file's first line as headers.
          default: None
      :param sep: separator for each column. default: ','
      :param dropna: whether to ignore and drop invalid data,
          if False, raise ValueError when reading invalid data. default: True
      :return: generator, every time yield (line number, csv item)
      """
  
      with open(path, "r", encoding=encoding) as csv_file:
          f = csv.reader(csv_file, delimiter=sep)
          start_idx = 0
          if headers is None:
              headers = next(f)
              start_idx += 1
          elif not isinstance(headers, (list, tuple)):
              raise TypeError(
                  "headers should be list or tuple, not {0}.".format(
                      type(headers)
                  )
              )
  
          for line_idx, line in enumerate(f, start_idx):
              contents = line
              if len(contents) != len(headers):
                  if dropna:
                      continue
                  else:
                      if "" in headers:
                          raise ValueError(
                              (
                                  "Line {0} has {1} parts, while header has "
                                  "{2} parts.\nPlease check the empty parts "
                                  "or unnecessary '{3}'s  in header."
                              ).format(
                                  line_idx,
                                  len(contents),
                                  len(headers),
                                  sep,
                              )
                          )
                      else:
                          raise ValueError(
                              "Line {0} has {1} parts, "
                              "while header has {2} parts.".format(
                                  line_idx, len(contents), len(headers)
                              )
                          )
              _dict = {}
              for header, content in zip(headers, contents):
                  _dict[header] = content
  
              yield line_idx, _dict
  
imports: import os
  import json
  import csv
label_desc: Use image node_id 1 for calling a global function with example usage: read_csv(path, encoding, headers, sep, dropna) without return types