code: def save_report_data(
      hash2group,
      groups_r_sorted,
      groups_t_sorted,
      trends_sorted,
      all_topics_sorted,
      create_clusters,
      target_header,
      ref_header,
      tfidf_w,
      cval_w,
      freq_w,
      in_model_count,
      top_n_scatter,
  ):
      filter_output = path.join(directory, "filter_phrases.csv")
      data_output = path.join(directory, "graph_data.csv")
      logger.info(
          "writing results to: %s and: %s ",
          str(data_output),
          str(filter_output),
      )
  
      reports_column = [
          "Top Topics (" + ref_header + ")",
          "Top Topics (" + target_header + ")",
          "Hot Trends",
          "Cold Trends",
          "Custom Trends",
      ]
      if create_clusters:
          reports_column.extend(
              [
                  "Trend Clustering",
                  "Topic Clustering (" + ref_header + ")",
                  "Topic Clustering (" + target_header + ")",
              ]
          )
      headers = [
          "reports",
          "ref_topic",
          "ref_imp",
          "x_ref",
          "y_ref",
          "tar_topic",
          "tar_imp",
          "x_tar",
          "y_tar",
          "trends",
          "change",
          "t_score",
          "x_tre",
          "y_tre",
          "weights",
          "in_w2v_model_count",
          "top_n_scatter",
      ]
      filter_headers = ["topics", "valid", "custom"]
      weights = [tfidf_w, cval_w, freq_w]
  
      with open(data_output, "wt", encoding="utf-8") as data_file:
          with open(
              filter_output, "wt", encoding="utf-8"
          ) as filter_file:
              data_writer = csv.writer(data_file, delimiter=",")
              filter_writer = csv.writer(filter_file, delimiter=",")
              data_writer.writerow(headers)
              filter_writer.writerow(filter_headers)
              for i in range(len(hash2group.keys())):
                  try:
                      new_row = ()
                      new_row += (
                          (reports_column[i],)
                          if i < len(reports_column)
                          else ("",)
                      )
                      if i < len(groups_r_sorted):
                          new_row += (
                              groups_r_sorted[i][0],
                              groups_r_sorted[i][1],
                          )
                          # 'only b' type tuple
                          if groups_r_sorted[i][2] == 0:
                              new_row += (
                                  (
                                      groups_r_sorted[i][-2],
                                      groups_r_sorted[i][-1],
                                  )
                                  if len(groups_r_sorted[i]) > 4
                                  else (-1, -1)
                              )
                          else:  # 'trend' type tuple
                              new_row += (
                                  (
                                      groups_r_sorted[i][-2],
                                      groups_r_sorted[i][-1],
                                  )
                                  if len(groups_r_sorted[i]) > 7
                                  else (-1, -1)
                              )
                      else:
                          new_row += ("", "", "", "")
                      if len(groups_t_sorted) > i:
                          new_row += (
                              groups_t_sorted[i][0],
                              groups_t_sorted[i][3],
                          )
                          # 'only a' type tuple
                          if groups_t_sorted[i][2] == 1:
                              new_row += (
                                  (
                                      groups_t_sorted[i][-2],
                                      groups_t_sorted[i][-1],
                                  )
                                  if len(groups_t_sorted[i]) > 5
                                  else (-1, -1)
                              )
                          else:
                              new_row += (
                                  (
                                      groups_t_sorted[i][-2],
                                      groups_t_sorted[i][-1],
                                  )
                                  if len(groups_t_sorted[i]) > 7
                                  else (-1, -1)
                              )
                      else:
                          new_row += ("", "", "", "")
                      if len(trends_sorted) > i:
                          new_row += (
                              trends_sorted[i][0],
                              trends_sorted[i][4],
                              trends_sorted[i][6],
                          )
                          new_row += (
                              (
                                  trends_sorted[i][-2],
                                  trends_sorted[i][-1],
                              )
                              if len(trends_sorted[i]) > 7
                              else (-1, -1)
                          )
                      else:
                          new_row += ("", "", "", "")
                      new_row += (
                          (weights[i],) if i < len(weights) else ("",)
                      )
                      new_row += (
                          (in_model_count, top_n_scatter)
                          if i == 0
                          else ("",)
                      )
                      data_writer.writerow(new_row)
                      filter_row = (all_topics_sorted[i], 1, 0)
                      filter_writer.writerow(filter_row)
                  except Exception as e:
                      logger.error(
                          "Error while writing analysis results. "
                          "iteration #: %s. Error: %s",
                          str(i),
                          str(e),
                      )
              if len(hash2group.keys()) < len(reports_column):
                  for i in range(
                      len(hash2group.keys()), len(reports_column)
                  ):
                      new_row = ()
                      new_row += (
                          reports_column[i],
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                          "",
                      )
                      data_writer.writerow(new_row)
  
imports: import argparse
  import csv
  import logging
  import operator
  import os
  import sys
  from os import path
  from pathlib import Path
  from shutil import copyfile
  import numpy
  import pandas
  from sklearn.manifold import TSNE
  from nlp_architect import LIBRARY_OUT
  from nlp_architect.utils.embedding import FasttextEmbeddingsModel
  from nlp_architect.utils.io import check_size, validate_existing_filepath
  from nlp_architect.utils.text import simple_normalizer
label_desc: Use image node_id 2 for calling a global function with example usage: save_report_data(hash2group, groups_r_sorted, groups_t_sorted, trends_sorted, all_topics_sorted, create_clusters, target_header, ref_header, tfidf_w, cval_w, freq_w, in_model_count, top_n_scatter) without return types