code: def _rejection_sampling_2D(
      n_samples, sigma, random_state=None, return_acceptance_rate=False
  ):
      """Rejection sampling algorithm for the 2D case.
  
      Implementation of a rejection sampling algorithm. The implementation
      follows the description given in page 528 of Christopher Bishop's book
      "Pattern recognition and Machine Learning" (2006).
  
      Parameters
      ----------
      n_samples : int
          Number of samples to get from the target distribution.
      sigma : float
          Dispersion of the Riemannian Gaussian distribution.
      random_state : int, RandomState instance or None, default=None
          Pass an int for reproducible output across multiple function calls.
      return_acceptance_rate : boolean, default=False
          Whether to return the acceptance rate with the sample (number of
          samples obtained divided by the number of samples generated by
          the algorithm).
  
          .. versionadded:: 0.5
  
      Returns
      -------
      r_samples : ndarray, shape (n_samples, n_dim)
          Samples of the r parameters of the Riemannian Gaussian distribution.
      acceptance_rate : float
          Acceptance rate empirically computed for the generation of the sample.
          Only returned if ``return_acceptance_rate=True``.
  
      Notes
      -----
      .. versionadded:: 0.4
  
      """
      mu_a = np.array([-(sigma**2) / 2, (sigma**2) / 2])
      mu_b = np.array([(sigma**2) / 2, -(sigma**2) / 2])
      cov_matrix = (sigma**2) * np.eye(2)
      r_samples = []
      cpt = 0
      acc = 0
      rs = check_random_state(random_state)
      while cpt != n_samples:
          acc += 1
          if rs.binomial(1, 0.5, 1) == 1:
              r_sample = multivariate_normal.rvs(
                  mu_a, cov_matrix, 1, rs
              )
              res = _rejection_sampling_2D_gfunction_plus(
                  sigma, r_sample
              )
              if rs.rand(1) < res:
                  r_samples.append(r_sample)
                  cpt += 1
          else:
              r_sample = multivariate_normal.rvs(
                  mu_b, cov_matrix, 1, rs
              )
              res = _rejection_sampling_2D_gfunction_minus(
                  sigma, r_sample
              )
              if rs.rand(1) < res:
                  r_samples.append(r_sample)
                  cpt += 1
  
      if return_acceptance_rate:
          return np.array(r_samples), n_samples / acc
      return np.array(r_samples)
  
file_path: pyRiemann/pyriemann/datasets/sampling.py
imports: from functools import partial
  import warnings
  import numpy
  from scipy.stats import multivariate_normal
  from sklearn.utils import check_random_state
  from joblib import Parallel, delayed
  from ..utils.base import sqrtm, expm
  from ..utils.test import is_sym_pos_semi_def
label_desc: Use image node_id 4 for calling a global function with example usage: _rejection_sampling_2D(n_samples, sigma, random_state, return_acceptance_rate) and returns: np, np,  unknown