code: def write_csv(csv_file, csv_lines, utt_id_idx=0, max_utt=300):
      """
      Write utterances to a .csv file.
  
      Parameters
      ----------
      csv_file : str
          Full path of the file to save
      csv_lines : list
          A list of lists containing the data to write to the .csv file.
      utt_id_idx : int
          Element in the list representing a line that marks the utterance id.
          This is necessary to keep track of duplicate utterances.
      max_utt : int
          Maximum number of duplicate utterances to be written.
          Once max_utt is exceeded, any lines containing the same
          utterance will not be written to the .csv file
      """
  
      # Keep track of the number of times each utterance appears
      utt2count = defaultdict(int)
  
      with open(csv_file, mode="w") as csv_f:
          csv_writer = csv.writer(
              csv_f,
              delimiter=",",
              quotechar='"',
              quoting=csv.QUOTE_MINIMAL,
          )
  
          for line in csv_lines:
              current_utt = line[utt_id_idx]
              # Avoid that the same utterance becomes part of the dataset too often
              if utt2count[current_utt] < max_utt:
                  csv_writer.writerow(line)
  
              utt2count[current_utt] += 1
  
imports: import re
  import csv
  import logging
  import os
  from collections import defaultdict
  from speechbrain.dataio.dataio import merge_csvs
  from speechbrain.utils.data_utils import download_file, get_all_files
label_desc: Use image node_id 2 for calling a global function with example usage: write_csv(csv_file, csv_lines, utt_id_idx, max_utt) without return types