code: def create_pairwise_bilateral(sdims, schan, img, chdim=-1):
      
      # Put channel dim in right position
      if chdim == -1:
          # We don't have a channel, add a new axis
          im_feat = img[np.newaxis].astype(np.float32)
      else:
          # Put the channel dim as axis 0, all others stay relatively the same
          im_feat = np.rollaxis(img, chdim).astype(np.float32)
  
      # scale image features per channel
      # Allow for a single number in `schan` to broadcast across all channels:
      if isinstance(schan, Number):
          im_feat /= schan
      else:
          for i, s in enumerate(schan):
              im_feat[i] /= s
  
      # create a mesh
      cord_range = [range(s) for s in im_feat.shape[1:]]
      mesh = np.array(np.meshgrid(*cord_range, indexing='ij'), dtype=np.float32)
  
      # scale mesh accordingly
      for i, s in enumerate(sdims):
          mesh[i] /= s
  
      feats = np.concatenate([mesh, im_feat])
      return feats.reshape([feats.shape[0], -1])
docs: Util function that create pairwise bilateral potentials. This works for
      all image dimensions. For the 2D case does the same as
      `DenseCRF2D.addPairwiseBilateral`.
  
      Parameters
      ----------
      sdims: list or tuple
          The scaling factors per dimension. This is referred to `sxy` in
          `DenseCRF2D.addPairwiseBilateral`.
      schan: list or tuple
          The scaling factors per channel in the image. This is referred to
          `srgb` in `DenseCRF2D.addPairwiseBilateral`.
      img: numpy.array
          The input image.
      chdim: int, optional
          This specifies where the channel dimension is in the image. For
          example `chdim=2` for a RGB image of size (240, 300, 3). If the
          image has no channel dimension (e.g. it has only one channel) use
          `chdim=-1`.