class_docstr: Segmentation Base Dataset
class_docstr_tok: ["Segmentation","Base","Dataset"]
code: def _sync_transform(self, img, mask):
      # random mirror
      if random.random() < 0.5:
          img = img.transpose(Image.FLIP_LEFT_RIGHT)
          mask = mask.transpose(Image.FLIP_LEFT_RIGHT)
      crop_size = self.crop_size
      # random scale (short edge)
      long_size = random.randint(
          int(self.base_size * 0.5), int(self.base_size * 2.0)
      )
      w, h = img.size
      if h > w:
          oh = long_size
          ow = int(1.0 * w * long_size / h + 0.5)
          short_size = ow
      else:
          ow = long_size
          oh = int(1.0 * h * long_size / w + 0.5)
          short_size = oh
      img = img.resize((ow, oh), Image.BILINEAR)
      mask = mask.resize((ow, oh), Image.NEAREST)
      # pad crop
      if short_size < crop_size:
          padh = crop_size - oh if oh < crop_size else 0
          padw = crop_size - ow if ow < crop_size else 0
          img = ImageOps.expand(img, border=(0, 0, padw, padh), fill=0)
          mask = ImageOps.expand(
              mask, border=(0, 0, padw, padh), fill=0
          )
      # random crop crop_size
      w, h = img.size
      x1 = random.randint(0, w - crop_size)
      y1 = random.randint(0, h - crop_size)
      img = img.crop((x1, y1, x1 + crop_size, y1 + crop_size))
      mask = mask.crop((x1, y1, x1 + crop_size, y1 + crop_size))
      # gaussian blur as in PSP
      if random.random() < 0.5:
          img = img.filter(
              ImageFilter.GaussianBlur(radius=random.random())
          )
      # final transform
      img, mask = self._img_transform(img), self._mask_transform(mask)
      return img, mask
  
file_path: gluon-cv/gluoncv/data/segbase.py
imports: import random
  import numpy
  from PIL import Image, ImageOps, ImageFilter
  import mxnet
  from mxnet import cpu
  import mxnet.ndarray
  from .base import VisionDataset
label_desc: Use image node_id 3 for calling the SegmentationDataset obj's underlying member method code with example usage: obj._sync_transform(img, mask) and returns: img,  mask