code: def _region_4(g1plus2g0, g0plus2g1, g0, g1, x):
      """Computes conditional and value for points in region 4."""
      del g1plus2g0, g0plus2g1
      # Reference: Eq. 32 in Ref [2]
      is_region_4 = ((g0 >= 0) & (g1 > 0)) | ((g0 <= 0) & (g1 < 0))
      eta = g1 / (g0 + g1)
      x_cap = tf.math.minimum(x, eta)
      x_floor = tf.math.maximum(x, eta)
      shift = -0.5 * (eta * g0 + (1 - eta) * g1)
      ratio_cap = (eta - x_cap) / eta
      ratio_floor = (x_floor - eta) / (1 - eta)
      region_4_value = (
          shift
          + (g0 - shift) * tf.math.square(ratio_cap)
          + (g1 - shift) * tf.math.square(ratio_floor)
      )
      # Integrated value: A x + (g0-A) eta ((eta-x)/eta)^3 / 3 for x < eta
      # and A x + (g1-A) (1-eta) [(x-eta)/(1-eta)]^3 / 3 for x > eta
      integrated_value = (
          shift * x
          + (g0 - shift) * eta * (1 - ratio_cap**3) / 3
          + (g1 - shift) * (1 - eta) * (ratio_floor**3) / 3
      )
      return is_region_4, region_4_value, integrated_value
  
file_path: tf-quant-finance/tf_quant_finance/rates/hagan_west/monotone_convex.py
imports: import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math.diff_ops import diff
  from tf_quant_finance.rates.analytics import forwards
label_desc: Use image node_id 8 for calling a global function with example usage: _region_4(g1plus2g0, g0plus2g1, g0, g1, x) and returns: is_region_4,  region_4_value,  integrated_value