code: def _np_d_s(
      preds, target, pan=None, pan_lr=None, norm_order=1, window_size=7
  ):
      np_preds = preds.permute(0, 2, 3, 1).cpu().numpy()
      if isinstance(target, dict):
          assert "ms" in target, "Expected `target` to contain 'ms'."
          np_ms = target["ms"].permute(0, 2, 3, 1).cpu().numpy()
          assert "pan" in target, "Expected `target` to contain 'pan'."
          np_pan = target["pan"].permute(0, 2, 3, 1).cpu().numpy()
          np_pan_lr = (
              target["pan_lr"].permute(0, 2, 3, 1).cpu().numpy()
              if "pan_lr" in target
              else None
          )
      else:
          np_ms = target.permute(0, 2, 3, 1).cpu().numpy()
          np_pan = pan.permute(0, 2, 3, 1).cpu().numpy()
          np_pan_lr = (
              pan_lr.permute(0, 2, 3, 1).cpu().numpy()
              if pan_lr is not None
              else None
          )
  
      return _baseline_d_s(
          np_preds,
          np_ms,
          np_pan,
          np_pan_lr,
          norm_order=norm_order,
          window_size=window_size,
      )
  
imports: from functools import partial
  from typing import Dict, List, NamedTuple
  import numpy
  import pytest
  import torch
  from scipy.ndimage import uniform_filter
  from skimage.transform import resize
  from torch import Tensor
  from torchmetrics.functional.image.d_s import spatial_distortion_index
  from torchmetrics.functional.image.uqi import universal_image_quality_index
  from torchmetrics.image.d_s import SpatialDistortionIndex
  from unittests import BATCH_SIZE, NUM_BATCHES
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 2 for calling a global function with example usage: _np_d_s(preds, target, pan, pan_lr, norm_order, window_size) and returns: _baseline_d_s