class_docstr: Noncentral Chi2 distribution.
  
  The Noncentral Chi2 distribution is defined over positive real numbers using a
  degrees of freedom ('df') and a noncentrality parameter.
  
  The Noncentral Chi2 arises as the distribution of the squared Euclidean norm
  of a 'df'-dimensional multivariate Gaussian distribution with mean vector
  'mu' and identity covariance. The noncentrality parameter is given by the
  squared Euclidean norm of the mean vector 'mu'.
  
  #### Mathematical Details
  
  The probability density function (pdf) is
  
  ```none
  pdf(x; df, nc, x > 0)
    = 0.5 * (x/nc)**(df/4 - 1/2) * exp(-(x + nc)/2) * I_{k/2 - 1}(sqrt(nc * x))
  ```
  
  where:
  
  * `df` denotes the degrees of freedom,
  * `nc` denotes the noncentrality
  * `I_{a}` is the modified Bessel function of the first kind of order `a`.
class_docstr_tok: ["Noncentral","Chi2","distribution",".","The","Noncentral","Chi2","distribution","is","defined","over","positive","real","numbers","using","a","degrees","of","freedom","(","'df","'",")","and","a","noncentrality","parameter",".","The","Noncentral","Chi2","arises","as","the","distribution","of","the","squared","Euclidean","norm","of","a","'df'-dimensional","multivariate","Gaussian","distribution","with","mean","vector","'mu","'","and","identity","covariance",".","The","noncentrality","parameter","is","given","by","the","squared","Euclidean","norm","of","the","mean","vector","'mu","'",".","#","#","#","#","Mathematical","Details","The","probability","density","function","(","pdf",")","is","``","`","none","pdf","(","x",";","df",",","nc",",","x",">","0",")","=","0.5","*","(","x\/nc",")","*","*","(","df\/4","-","1\/2",")","*","exp","(","-","(","x","+","nc",")","\/2",")","*","I_","{","k\/2","-","1","}","(","sqrt","(","nc","*","x",")",")","``","`","where",":","*","`","df","`","denotes","the","degrees","of","freedom",",","*","`","nc","`","denotes","the","noncentrality","*","`","I_","{","a","}","`","is","the","modified","Bessel","function","of","the","first","kind","of","order","`","a","`","."]
code: def _sample_n(self, n, seed=None):
      shape = ps.concat(
          [
              [n],
              self._batch_shape_tensor(
                  df=self.df, noncentrality=self.noncentrality
              ),
          ],
          axis=0,
      )
  
      df = tf.broadcast_to(self.df, shape)
      noncentrality = tf.broadcast_to(self.noncentrality, shape)
  
      (
          chi2_seed,
          norm_seed,
          pois_seed,
          nc_chi2_seed,
      ) = tfp_random.split_seed(seed, n=4)
  
      # Ensures that the df parameter passed to `random_gamma` is valid and
      # can be short-circuited fast.
      high_df_mask = df > 1.0
      safe_df = tf.where(high_df_mask, df, 2.0)
  
      # Generate the samples for the case when df > 1
      numpy_dtype = dtype_util.as_numpy_dtype(self.dtype)
      half = numpy_dtype(0.5)
      chi2_samps = gamma_lib.random_gamma(
          shape=[],
          concentration=0.5 * (safe_df - 1.0),
          rate=half,
          seed=chi2_seed,
      )
  
      normal_samps = samplers.normal(
          shape=shape,
          mean=tf.math.sqrt(noncentrality),
          dtype=self.dtype,
          seed=norm_seed,
      )
  
      nc_chi2_samps_high_df = chi2_samps + tf.math.square(normal_samps)
  
      # Generate the samples for the case when df < 1
      poisson_samps = poisson_lib.random_poisson(
          shape=[],
          rates=0.5 * noncentrality,
          output_dtype=self.dtype,
          seed=pois_seed,
      )[0]
  
      nc_chi2_samps_low_df = gamma_lib.random_gamma(
          shape=[],
          concentration=0.5 * (df + 2.0 * poisson_samps),
          rate=half,
          seed=nc_chi2_seed,
      )
  
      return tf.where(
          high_df_mask, nc_chi2_samps_high_df, nc_chi2_samps_low_df
      )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import chi2
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import special_math
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math import bessel
  from tensorflow_probability.python.math import generic
  from tensorflow_probability.python.math import root_search
  import tensorflow_probability.python.random
label_desc: Use image node_id 7 for calling the NoncentralChi2 obj's underlying member method code with example usage: obj._sample_n(n, seed) and returns: tf