code: def make_tarreg_loss(
      ratio=1.0, dragonnet_loss=dragonnet_loss_binarycross
  ):
      """
      Given a specified loss function, returns the same loss function with targeted regularization.
  
      Args:
          ratio (float): weight assigned to the targeted regularization loss component
          dragonnet_loss (function): a loss function
      Returns:
          (function): loss function with targeted regularization, weighted by specified ratio
      """
  
      def tarreg_ATE_unbounded_domain_loss(concat_true, concat_pred):
          """
          Returns the loss function (specified in outer function) with targeted regularization.
          """
          vanilla_loss = dragonnet_loss(concat_true, concat_pred)
  
          y_true = concat_true[:, 0]
          t_true = concat_true[:, 1]
  
          y0_pred = concat_pred[:, 0]
          y1_pred = concat_pred[:, 1]
          t_pred = concat_pred[:, 2]
  
          epsilons = concat_pred[:, 3]
          t_pred = (t_pred + 0.01) / 1.02
          # t_pred = tf.clip_by_value(t_pred,0.01, 0.99,name='t_pred')
  
          y_pred = t_true * y1_pred + (1 - t_true) * y0_pred
  
          h = t_true / t_pred - (1 - t_true) / (1 - t_pred)
  
          y_pert = y_pred + epsilons * h
          targeted_regularization = tf.reduce_sum(
              tf.square(y_true - y_pert)
          )
  
          # final
          loss = vanilla_loss + ratio * targeted_regularization
          return loss
  
      return tarreg_ATE_unbounded_domain_loss
  
file_path: causalml/causalml/inference/tf/utils.py
imports: import tensorflow
  from tensorflow.keras import backend
  from tensorflow.keras.layers import Layer
  from tensorflow.keras.metrics import binary_accuracy
label_desc: Use image node_id 6 for calling a global function with example usage: make_tarreg_loss(ratio, dragonnet_loss) and returns: tarreg_ATE_unbounded_domain_loss, loss