docs: def serialize_to_dict(dictionary):
      '''Make a json-serializable dictionary from input dictionary by converting
      non-serializable data types such as numpy arrays.'''
      retval = {}
      
      for k, v in dictionary.items():
          if isinstance(v, dict):
              retval[k] = serialize_to_dict(v)
          else:
              # This is when custom serialization happens
              if isinstance(v, np.ndarray):
                  if v.dtype == 'float64':
                      # We don't support float64 on js side
                      v = v.astype('float32')
  
                  retval[k] = encode_numpy(v)
              else:
                  retval[k] = v
      
      return retval