class_docstr: A tool for image augmentation.
  
  For operations with inplace=True, the returned value is the ImageTool
  instance self, which is for chaining multiple operations; Otherwise, the
  preprocessed images would be returned.
  
  For operations that has countable pre-processing cases, argument num_case
  could be set to decide the number of pre-processing cases to apply.
  Typically, it is set to 1 for training phases and to the max for test
  phases.
class_docstr_tok: ["A","tool","for","image","augmentation",".","For","operations","with","inplace=True",",","the","returned","value","is","the","ImageTool","instance","self",",","which","is","for","chaining","multiple","operations",";","Otherwise",",","the","preprocessed","images","would","be","returned",".","For","operations","that","has","countable","pre-processing","cases",",","argument","num_case","could","be","set","to","decide","the","number","of","pre-processing","cases","to","apply",".","Typically",",","it","is","set","to","1","for","training","phases","and","to","the","max","for","test","phases","."]
docstr: Crop the image at random offset to get a patch of the given size.
  
  Args:
      patch(tuple): width and height of the patch
      inplace(Boolean): replace the internal images list with the patches
                        if True; otherwise, return the patches.
code: def random_crop(self, patch, inplace=True):
      """Crop the image at random offset to get a patch of the given size.
  
      Args:
          patch(tuple): width and height of the patch
          inplace(Boolean): replace the internal images list with the patches
                            if True; otherwise, return the patches.
      """
      new_imgs = []
      for img in self.imgs:
          assert (
              img.size[0] >= patch[0] and img.size[1] >= patch[1]
          ), "img size (%d, %d), patch size (%d, %d)" % (
              img.size[0],
              img.size[1],
              patch[0],
              patch[1],
          )
          left_offset = random.randint(0, img.size[0] - patch[0])
          top_offset = random.randint(0, img.size[1] - patch[1])
          box = (
              left_offset,
              top_offset,
              left_offset + patch[0],
              top_offset + patch[1],
          )
          new_imgs.append(img.crop(box))
  
      if inplace:
          self.imgs = new_imgs
          return self
      else:
          return new_imgs
  
imports: from __future__ import division
  from builtins import range
  from builtins import object
  import random
  import numpy
  from PIL import Image, ImageEnhance
  import math
label_desc: Use image node_id 18 for calling the ImageTool obj's underlying member method code with example usage: obj.random_crop(patch, inplace) and returns: self, new_imgs