code: def downsample_seg_for_ds_transform2(
      seg,
      ds_scales=((1, 1, 1), (0.5, 0.5, 0.5), (0.25, 0.25, 0.25)),
      order=0,
      axes=None,
  ):
      if axes is None:
          axes = list(range(2, len(seg.shape)))
      output = []
      for s in ds_scales:
          if all([i == 1 for i in s]):
              output.append(seg)
          else:
              new_shape = np.array(seg.shape).astype(float)
              for i, a in enumerate(axes):
                  new_shape[a] *= s[i]
              new_shape = np.round(new_shape).astype(int)
              out_seg = np.zeros(new_shape, dtype=seg.dtype)
              for b in range(seg.shape[0]):
                  for c in range(seg.shape[1]):
                      out_seg[b, c] = resize_segmentation(
                          seg[b, c], new_shape[2:], order
                      )
              output.append(out_seg)
      return output
  
imports: import random
  import numpy
  import paddle
  from paddle.nn.functional import avg_pool2d, avg_pool3d
  from typing import List, Tuple, Union, Callable
  from copy import deepcopy
  from scipy.ndimage import map_coordinates, fourier_gaussian
  from scipy.ndimage.filters import gaussian_filter, gaussian_gradient_magnitude
  from scipy.ndimage.morphology import grey_dilation
  from skimage.transform import resize
  from scipy.ndimage.measurements import label
label_desc: Use image node_id 2 for calling a global function with example usage: downsample_seg_for_ds_transform2(seg, ds_scales, order, axes) and returns: output