code: def _sample_categories_from_latent(
      latent_mean: np.ndarray,
      distribution: str,
      noise_std: float,
      root_node: bool,
  ) -> np.ndarray:
      one_hot = np.empty_like(latent_mean)
      n_samples, n_cardinality = latent_mean.shape
  
      # try and get the requested distribution from the mapper
      distribution_func = __distribution_mapper.get(distribution, None)
      if distribution_func is None:
          _raise_dist_error(
              "categorical",
              distribution,
              ["logit", "gumbel", "probit", "normal"],
          )
  
      # add noise to mean
      latent_mean += _handle_distribution_sampling(
          distribution=distribution,
          distribution_func=distribution_func,
          noise_std=noise_std,
          size=(n_samples, n_cardinality),
          root_node=root_node,
      )
  
      x_cat = np.argmax(latent_mean, axis=1)
  
      for i in range(n_cardinality):
          one_hot[:, i] = (x_cat == i).astype(int)
  
      return one_hot
  
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 9 for calling a global function with example usage: _sample_categories_from_latent(latent_mean, distribution, noise_std, root_node) and returns: one_hot