code: def _approx_implied_vol_polya(
      normalized_prices,
      normalized_forwards,
      expiries,
      is_call_options,
      polya_factor,
  ):
      """Computes approximate implied vol using the Stefanica-Radoicic algorithm.
  
      ## Implementation Notes
      The mapping between the notation used in the reference paper and the code
      below is as follows:
        y -> log_normalized_forwards
        alpha_c -> normalized_prices
      This notation is used in the in-line comments.
  
      Args:
        normalized_prices: `Tensor` of real dtype and any shape. The prices of the
          options to be inverted. Normalization means that the raw price is divided
          by the strike discounted to the present.
        normalized_forwards: `Tensor` or same dtype and shape as `normalized_prices`
          The forwards divided by the strike of the options.
        expiries: A real `Tensor` of same shape and dtype as `normalized_forwards`.
          The expiry for each option.
        is_call_options: Boolean `Tensor` of same shape as `normalized_prices` or
          None. Indicates whether a price is for a call option (if True) or a put
          option (if False). If None is specified, it is assumed that all the
          options are call options.
        polya_factor: Scalar `Tensor` of same dtype as `normalized_prices`. This is
          the factor to use for approximating the normal CDF in a Polya-like
          expression. Polya approximation is: N(x) ~ 0.5 + sign(x) sqrt(1-e^(-k
            x^2)) with k = 2 / pi. However, it has been found that other values for
            `k` may be more accurate. The value that minimizes the absolute error
            over the range [-10, 10] is 0.62305051 (approximately 5/8).
  
      Returns:
        implied_vols: A `Tensor` of same shape and dtype as
          `undiscounted_prices`. The approximate implied volatilities
          computed using the Polya approximation for the normal CDF.
      """
      if polya_factor is None:
          polya_factor = tf.convert_to_tensor(
              2.0 / np.pi, dtype=normalized_prices.dtype
          )
      floored_forwards = tf.math.maximum(normalized_forwards, 1)
      capped_forwards = tf.math.minimum(normalized_forwards, 1)
  
      log_normalized_forwards = tf.math.log(normalized_forwards)
      sign_log_forward = tf.math.sign(log_normalized_forwards)
  
      if is_call_options is not None:
          is_call_options = tf.convert_to_tensor(
              is_call_options, dtype=tf.bool, name="is_call_options"
          )
          ones = tf.ones_like(
              is_call_options, dtype=normalized_forwards.dtype
          )
          option_signs = tf.where(is_call_options, ones, -ones)
      else:
          option_signs = 1
      signs = option_signs * sign_log_forward
  
      cdfs = 0.5 + 0.5 * signs * tf.math.sqrt(
          -tf.math.expm1(
              -2 * polya_factor * tf.math.abs(log_normalized_forwards)
          )
      )
  
      # This corresponds to the expressions C_0 or P_0 in the table 2 of Ref [1].
      threshold = signs * (
          floored_forwards * cdfs - capped_forwards / 2
      )
  
      a, b, lnc = _get_quadratic_coeffs(
          normalized_prices,
          normalized_forwards,
          log_normalized_forwards,
          option_signs,
          polya_factor,
      )
      c = tf.math.exp(lnc)
      lntwo = tf.convert_to_tensor(
          np.log(2.0), dtype=normalized_forwards.dtype
      )
      lnbeta = (
          lntwo + lnc - tf.math.log(b + tf.math.sqrt(b * b + 4 * a * c))
      )
      gamma = -lnbeta / polya_factor
  
      term1 = tf.math.sqrt(gamma + log_normalized_forwards)
      term2 = tf.math.sqrt(gamma - log_normalized_forwards)
      sqrt_var = tf.where(
          normalized_prices <= threshold,
          sign_log_forward * (term1 - term2),
          term1 + term2,
      )
      return sqrt_var / tf.math.sqrt(expiries)
  
imports: import numpy
  import tensorflow.compat.v2
label_desc: Use image node_id 3 for calling a global function with example usage: _approx_implied_vol_polya(normalized_prices, normalized_forwards, expiries, is_call_options, polya_factor) and returns: unknown