code: def _test_brain_seg(
      model,
      niters=3,
      beta=0,
      ngb_size=6,
      init_params=None,
      convert=True,
  ):
      S = BrainT1Segmentation(
          anat_img.get_fdata(),
          mask=anat_mask,
          model=model,
          niters=niters,
          beta=beta,
          ngb_size=ngb_size,
          init_params=init_params,
          convert=convert,
      )
      shape = anat_img.shape
      if convert:
          nclasses = 3
      else:
          nclasses = S.mixmat.shape[0]
      # Check that the class attributes have appropriate dimensions
      _check_dims(S.ppm, 4, list(shape) + [nclasses])
      _check_dims(S.label, 3, shape)
      _check_dims(S.mu, 1, S.mixmat.shape[0])
      _check_dims(S.sigma, 1, S.mixmat.shape[0])
      # Check that probabilities are zero outside the mask and sum up to
      # one inside the mask
      assert_almost_equal(S.ppm[~S.mask].sum(-1).max(), 0)
      assert_almost_equal(S.ppm[S.mask].sum(-1).min(), 1)
      # Check that labels are zero outside the mask and > 1 inside the
      # mask
      assert_almost_equal(S.label[~S.mask].max(), 0)
      assert_almost_equal(S.label[S.mask].min(), 1)
  
imports: from numbers import Number
  import numpy
  from numpy.testing import assert_almost_equal, assert_array_almost_equal
  from ....io.files import load
  from ....testing import anatfile
  from ..brain_segmentation import BrainT1Segmentation
  from ..segmentation import Segmentation
label_desc: Use image node_id 2 for calling a global function with example usage: _test_brain_seg(model, niters, beta, ngb_size, init_params, convert) without return types