code: def filter_baseline_layout(
      layout,
      sample,
      kernel,
      anchor,
      border,
      fill_value=None,
      mode="same",
  ):
      ndim = len(sample.shape)
      if not layout:
          assert ndim in (2, 3), f"{sample.shape}"
          layout = "HW" if ndim == 2 else "DHW"
      assert len(layout) == ndim, f"{layout}, {sample.shape}"
      has_channels = layout[ndim - 1] == "C"
  
      def baseline_call(plane):
          return filter_baseline(
              plane,
              kernel,
              anchor,
              border,
              fill_value,
              mode,
              has_channels=has_channels,
          )
  
      def get_seq_ndim():
          for i, c in enumerate(layout):
              if c not in "FC":
                  return i
          assert False
  
      seq_ndim = get_seq_ndim()
      if seq_ndim == 0:
          return baseline_call(sample)
      else:
          seq_shape = sample.shape[:seq_ndim]
          spatial_shape = sample.shape[seq_ndim:]
          seq_vol = np.prod(seq_shape)
          sample = sample.reshape((seq_vol,) + spatial_shape)
          out = np.stack([baseline_call(plane) for plane in sample])
          return out.reshape(seq_shape + out.shape[1:])
  
imports: import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: filter_baseline_layout(layout, sample, kernel, anchor, border, fill_value, mode) and returns: filter_baseline, baseline_call, out, i