code: def write_json(file_path, data, do_clear=False):
      """Write `data` to the JSON file specified by `file_path`, optionally clearing the file before
      adding `data`
  
      Parameters
      ----------
      file_path: String
          The target .json file path to which `data` will be written
      data: Object
          The content to save at the .json file given by `file_path`
      do_clear: Boolean, default=False
          If True, the contents of the file at `file_path` will be cleared before saving `data`
      """
      if do_clear is True:
          clear_file(file_path)
  
      with open(file_path, "w") as f:
          json.dump(
              data, f, default=default_json_write, tuple_as_array=False
          )
  
imports: from hyperparameter_hunter.settings import G
  from contextlib import suppress
  from inspect import signature
  import numpy
  import os
  import os.path
  import pandas
  import simplejson
  from typing import Union
  import wrapt
label_desc: Use image node_id 3 for calling a global function with example usage: write_json(file_path, data, do_clear) without return types