code: def convert_to_binary(x, stochastic=True):
      p = sigmoid(x)
      if stochastic:
          return choice([0, 1], 1, p=[1 - p, p])
      else:
          return int(p > 0.5)
  
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 2 for calling a global function with example usage: convert_to_binary(x, stochastic) and returns: choice, int