code: def img2pyt(img, add_batch_dim=True, resize=None):
      from torchvision import (
          transforms,
      )  # expensive function-level import
  
      ts = []
      if resize is not None:
          ts.append(transforms.RandomResizedCrop(resize))
      ts.append(transforms.ToTensor())
      img_pyt = transforms.Compose(ts)(img)
      if add_batch_dim:
          img_pyt.unsqueeze_(0)
      return img_pyt
  
file_path: tensorwatch/tensorwatch/image_utils.py
imports: import numpy
  import math
  import time
label_desc: Use image node_id 7 for calling a global function with example usage: img2pyt(img, add_batch_dim, resize) and returns: img_pyt