code: def merge_phrases(
      data, is_ref_data, hash2group, rep2rank, top_n, topics_count
  ):
      """
      Analyze the provided topics data and detect trends (changes in importance)
  
      Args:
          data: A list of topics with importance scores
          is_ref_data (Boolean): Was the data extracted from the target/reference corpus
          hash2group: A dictionary storing the data of each topic
          rep2rank: A dict of all groups representatives and their ranks
          top_n (int): Limit the analysis to only the top N phrases of each list
          topics_count (int): The total sum of all topics extracted from both corpora
      """
      logger.info("merge and compare groups for data: %s", str(data))
      ctr = 0
      if not Path(data).exists():
          logger.error("invalid csv file: %s", str(data))
          sys.exit()
      try:
          with open(
              data, encoding="utf-8", errors="ignore"
          ) as csv_file:
              topics = csv.reader(csv_file, delimiter=",")
              for group, imp in topics:
                  if ctr == top_n:
                      break
                  try:
                      rep = clean_group(group).strip()
                      imp = float(imp) * 100.0
                      rank = ctr + 1
                      hash_id = simple_normalizer(rep)
                      if hash_id not in hash2group:
                          rep2rank[rep] = rank
                          if is_ref_data:
                              hash2group[hash_id] = (rep, imp, 0, rank)
                          else:
                              hash2group[hash_id] = (
                                  rep,
                                  0,
                                  1,
                                  imp,
                                  rank,
                              )
                      elif not is_ref_data:
                          data_b = hash2group[hash_id]
                          if (
                              data_b[2] == 0
                          ):  # create a trend only in comparison to the
                              #  ref topics, ignore cases of different topics have the
                              # same hash or same topic was extracted twice from the
                              # same data
                              old_rep = data_b[0]
                              old_rank = data_b[3]
                              rep2rank[old_rep] = int(
                                  (rank + old_rank) / 2
                              )  # rank
                              #  of topic that appear in both corpora calculated as
                              #  the avarage of ranks
                              change = float(imp) - float(data_b[1])
                              t_score = (
                                  topics_count - (old_rank + rank)
                              ) * abs(change)
                              hash2group[hash_id] = (
                                  old_rep,
                                  float(data_b[1]),
                                  2,
                                  imp,
                                  change,
                                  abs(change),
                                  t_score,
                              )  # trend phrase
                      ctr += 1
                  except Exception as e:
                      logger.error(
                          "bad line: %s. Error: %s", str(ctr), str(e)
                      )
      except Exception as e:
          logger.error(
              "Error: %s. Is %s a valid csv file?", str(e), str(data)
          )
          sys.exit()
  
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 6 for calling a global function with example usage: merge_phrases(data, is_ref_data, hash2group, rep2rank, top_n, topics_count) without return types