code: def write_results(df, filename, format):
      if format == "latex":
          tmp_df = df.copy()
          tmp_df.columns = pd.MultiIndex.from_tuples(tmp_df.columns)
          with open(filename, "a") as file:
              file.write(tmp_df.to_latex())
      elif format == "csv":
          with open(filename, "a") as file:
              file.write(df.to_csv())
      else:
          raise ValueError("Unknown format: " + format)
  
      print(format + " results written to: " + filename)
  
label_desc: Use image node_id 2 for calling a global function with example usage: write_results(df, filename, format) without return types