code: def ncx2cdf_and_gradient(x, k, l, truncation=10):
      """Returns the CDF of noncentral X2 distribution and its gradient over l.
  
      Args:
        x: Values of the random variable following a noncentral X2 distribution. A
          real `Tensor`.
        k: Degrees of freedom. A positive real `Tensor` of same shape as `x`.
        l: Non-centrality parameter. A positive real `Tensor` of same shape as `x`.
        truncation: A positive integer. When computing the CDF of a noncentral X2
          distribution, it needs to calculate the sum of an expression from 0 to
          infinity. In practice, it needs to be truncated to compute an approximate
          value. This argument is the index of the last
            term that will be included in the sum. Default value: 10.
  
      Returns:
        A tuple of two `Tensor`s. The first `Tensor` is the CDF. The second
        `Tensor` is the gradient of the CDF over l. Both of the `Tensors` are of
        same shape as `x`.
      """
      g = 0.0
      dg = 0.0
      factorial = 1.0
      for j in range(truncation + 1):
          factorial *= j if j > 0 else 1
          h = (
              1 - tf.math.igammac((k + 2 * j) / 2.0, x / 2.0)
          ) / factorial
          g += h * (l * 0.5) ** j
          dg += h * 0.5 * j * (l * 0.5) ** (j - 1)
      f = tf.math.exp(-0.5 * l)
      df = -0.5 * f
      p = f * g
      dp = df * g + f * dg
      return p, dp
  
file_path: tf-quant-finance/tf_quant_finance/models/sabr/sabr_model.py
imports: from typing import Optional
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import random_ops
  from tf_quant_finance.math.root_search.newton import root_finder
  from tf_quant_finance.models import generic_ito_process
  from tf_quant_finance.models import utils
label_desc: Use image node_id 1 for calling a global function with example usage: ncx2cdf_and_gradient(x, k, l, truncation) and returns: p,  dp