code: def test_finalize_to_json():
      df = pd.read_parquet(
          "h2oGPT.cleaned.graded.human_bot.shorter.parquet"
      )
      df = df.rename(columns={"text": "input"})
  
      print(
          "Number of high-quality human_bot interactions: %s"
          % df.shape[0],
          flush=True,
      )
  
      print("Adding open assistant data")
      with open("openassistant_oasst1_h2ogpt_graded.json") as f:
          open_assistant = json.loads(f.read())
      df = pd.concat([df, pd.DataFrame(open_assistant)], axis=0)
  
      def final_clean(df):
          from better_profanity import profanity
  
          profanity.load_censor_words_from_file("data/censor_words.txt")
          df["profanity"] = parallel_apply(
              df["input"],
              lambda x: profanity.contains_profanity(x),
              n_jobs=-1,
          )
          return df[(df["profanity"] == 0)].reset_index(drop=True)
  
      print(
          "Before cleaning: Number of final high-quality human_bot interactions: %s"
          % df.shape[0],
          flush=True,
      )
      df = final_clean(df)
      print(
          "After cleaning: Number of final high-quality human_bot interactions: %s"
          % df.shape[0],
          flush=True,
      )
      print(df.describe())
      print(df.shape)
      row_list = []
      for i in range(df.shape[0]):
          row_list.append(
              dict(
                  input=df.loc[i, "input"],
                  source=df.loc[i, "source"],
                  prompt_type="plain",
              )
          )
      np.random.seed(1234)
      np.random.shuffle(row_list)
      unhelpful = get_unhelpful_list()
      row_list = [
          x
          for x in row_list
          if not any(u in x["input"] for u in unhelpful)
      ]
      for i in range(len(row_list)):
          row_list[i]["id"] = i
          row_list[i]["input"] = row_list[i]["input"].replace(
              " <bot>:", "\n<bot>:"
          )
      with open("h2ogpt-oig-oasst1-instruct-cleaned-v3.json", "w") as f:
          f.write(json.dumps(row_list, indent=2))
  
imports: import ast
  import concurrent.futures
  import contextlib
  import hashlib
  import json
  import os
  import shutil
  import signal
  import sys
  import traceback
  from concurrent.futures import ProcessPoolExecutor
  import psutil
  import pytest
  import pandas
  import numpy
  from tqdm import tqdm
  from utils import flatten_list, remove
  from joblib import Parallel, delayed, effective_n_jobs
  from sklearn.utils import gen_even_slices
  from sklearn.utils.validation import _num_samples
label_desc: Use image node_id 33 for calling a global function with example usage: test_finalize_to_json() and returns: df