code: def convert_to_categorical(
      arr,
      num_vars,
      num_discrete_vars,
      quantiles=[0.25, 0.5, 0.75],
      one_hot_encode=False,
  ):
      arr_with_dummy = arr.copy()
      # Below loop assumes that the last indices of W are alwawys converted to discrete
      for arr_index in range(num_vars - num_discrete_vars, num_vars):
          # one-hot encode discrete W
          arr_bins = np.quantile(arr[:, arr_index], q=quantiles)
          arr_categorical = np.digitize(
              arr[:, arr_index], bins=arr_bins
          )
          if one_hot_encode:
              dummy_vecs = np.eye(len(quantiles) + 1)[arr_categorical]
              arr_with_dummy = np.concatenate(
                  (arr_with_dummy, dummy_vecs), axis=1
              )
          else:
              arr_with_dummy = np.concatenate(
                  (arr_with_dummy, arr_categorical[:, np.newaxis]),
                  axis=1,
              )
      # Now deleting the old continuous value
      for arr_index in range(
          num_vars - 1, num_vars - num_discrete_vars - 1, -1
      ):
          arr_with_dummy = np.delete(arr_with_dummy, arr_index, axis=1)
      return arr_with_dummy
  
imports: import math
  import string
  import networkx
  import numpy
  import pandas
  import scipy.stats
  from numpy.random import choice
  from scipy.stats import bernoulli, halfnorm, poisson, uniform
  from sklearn.neural_network import MLPRegressor
  from dowhy.utils.graph_operations import add_edge, del_edge, get_random_node_pair, get_simple_ordered_tree
label_desc: Use image node_id 4 for calling a global function with example usage: convert_to_categorical(arr, num_vars, num_discrete_vars, quantiles, one_hot_encode) and returns: arr_with_dummy