code: def _sample_poisson(
      expected_count: np.ndarray, max_count: int = 5000
  ) -> np.ndarray:
      """
      Samples from a poisson distribution using each element in ``latent_mean``
      as the Poisson parameter.
  
      Args:
          expected_count: Event rate of the Poisson process, can be of any array
              dimension. Defined on (0, infty).
          max_count: Bounds the count from above. The count sample is created
              with a while loop. This argument is the maximum number of loop
              iterations before stopping. Default value should run on most
              machines in reasonable amount of time.
      Returns:
          Sampled count of a Poisson distribution from the given mean.
      """
      # use log for numeric stability for large count values
      log_cond_intensity = -expected_count
      log_intensity_budget = np.copy(log_cond_intensity)
  
      count = np.zeros_like(expected_count)
  
      log_uni = np.log(np.random.uniform(size=expected_count.shape))
      mask = log_uni >= log_intensity_budget
  
      while np.any(mask) and count.max() < max_count:
          mask = log_uni >= log_intensity_budget
          count[mask] += 1
          log_cond_intensity[mask] += np.log(
              expected_count[mask] / count[mask]
          )
          log_intensity_budget[mask] = np.logaddexp(
              log_intensity_budget[mask], log_cond_intensity[mask]
          )
  
      return count
  
imports: from typing import Dict, Hashable, List, Optional, Tuple, Union
  import networkx
  import numpy
  import pandas
  from sklearn.gaussian_process.kernels import RBF, Kernel
  from causalnex.structure import StructureModel
  from causalnex.structure.categorical_variable_mapper import VariableFeatureMapper, validate_schema
label_desc: Use image node_id 8 for calling a global function with example usage: _sample_poisson(expected_count, max_count) and returns: count