code: def test_sample_binary_from_latent_imbalance(
      max_imbalance, distribution
  ):
      """
      Tests max imbalance argument to sample the binary variable.
      This way we are guaranteed to always have some positives/negatives.
      """
      # corner case:
      eta = np.ones(1000) * 1000
  
      sample = _sample_binary_from_latent(
          latent_mean=eta,
          distribution=distribution,
          noise_std=0.1,
          root_node=False,
          max_imbalance=max_imbalance,
      )
      tol = 0.01
      assert np.isclose(sample.mean(), max_imbalance, atol=0, rtol=tol)
  
imports: import operator
  from typing import Hashable, Tuple, Union
  import networkx
  import numpy
  import pandas
  import pytest
  from networkx.algorithms.dag import is_directed_acyclic_graph
  from sklearn.gaussian_process.kernels import RBF
  from causalnex.structure.data_generators.core import _sample_binary_from_latent, _sample_count_from_latent, _sample_poisson, generate_structure, nonlinear_sem_generator, sem_generator
  from causalnex.structure.structuremodel import StructureModel
label_desc: Use image node_id 4 for calling a global function with example usage: test_sample_binary_from_latent_imbalance(max_imbalance, distribution) without return types