code: def _region_3(g1plus2g0, g0plus2g1, g0, g1, x):
      """Computes conditional and value for points in region 3."""
      del g1plus2g0
      # Reference: Eq. 30, 31 in Ref [2]
      is_region_3 = ((g1 <= 0) & (g0plus2g1 > 0)) | (
          (g1 >= 0) & (g0plus2g1 < 0)
      )
      eta = 3 * g1 / (g1 - g0)
      x_cap = tf.math.minimum(x, eta)
      ratio = (eta - x_cap) / eta
      # Replace NaN values (corresponding to g1 == 0) with zeros.
      ratio = tf.where(
          tf.math.is_nan(ratio), tf.zeros_like(ratio), ratio
      )
      region_3_value = g1 + (g0 - g1) * tf.math.square(ratio)
      integrated_value = g1 * x + eta * (g0 - g1) / 3 * (1 - ratio**3)
      return is_region_3, region_3_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 7 for calling a global function with example usage: _region_3(g1plus2g0, g0plus2g1, g0, g1, x) and returns: is_region_3,  region_3_value,  integrated_value