code: def _sample_binary_from_latent(
      latent_mean: np.ndarray,
      distribution: str,
      noise_std: float,
      root_node: bool,
      max_imbalance: float = 0.05,
  ) -> np.ndarray:
      n_samples = latent_mean.shape[0]
  
      # try and get the requested distribution from the mapper
      distribution_func = __distribution_mapper.get(distribution, None)
      if distribution_func is None:
          _raise_dist_error(
              "binary", distribution, ["logit", "probit", "normal"]
          )
  
      # add noise to mean
      latent_mean += _handle_distribution_sampling(
          distribution=distribution,
          distribution_func=distribution_func,
          noise_std=noise_std,
          size=(n_samples,),
          root_node=root_node,
      )
  
      # use an alternative threshold if 0 leads to heavy imbalance
      labels = (latent_mean > 0).astype(int)
      share_positive = np.mean(labels)
      if share_positive < max_imbalance:
          return (
              latent_mean > np.quantile(latent_mean, max_imbalance)
          ).astype(int)
      if share_positive > (1 - max_imbalance):
          return (
              latent_mean > np.quantile(latent_mean, 1 - max_imbalance)
          ).astype(int)
      return labels
  
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 5 for calling a global function with example usage: _sample_binary_from_latent(latent_mean, distribution, noise_std, root_node, max_imbalance) and returns: labels, unknown, unknown