code: def _px_bounds(x, dim):
      c = x.sum(dim).nonzero().cpu()
      idxs, vals = torch.unique(c[:, 0], return_counts=True)
      vs = torch.split_with_sizes(c[:, 1], tuple(vals))
      d = {k.item(): v for k, v in zip(idxs, vs)}
      default_u = tensor([0, x.shape[-1] - 1])
      b = [d.get(o, default_u) for o in range(x.shape[0])]
      b = [tensor([o.min(), o.max()]) for o in b]
      return torch.stack(b)
  
imports: from __future__ import annotations
  from ..basics import *
  from ..vision.all import *
  from ..data.transforms import *
  import pydicom, kornia, skimage
  from pydicom.dataset import Dataset
  from pydicom.tag import BaseTag
  from pydicom.multival import MultiValue
  from PIL import Image
label_desc: Use image node_id 20 for calling a global function with example usage: _px_bounds(x, dim) and returns: torch