class_docstr: Crops the given ndarray image (H*W*C or H*W).
  Args:
      size (sequence or int): Desired output size of the crop. If size is an
      int instead of sequence like (h, w), a square crop (size, size) is made.
class_docstr_tok: ["Crops","the","given","ndarray","image","(","H","*","W","*","C","or","H","*","W",")",".","Args",":","size","(","sequence","or","int",")",":","Desired","output","size","of","the","crop",".","If","size","is","an","int","instead","of","sequence","like","(","h",",","w",")",",","a","square","crop","(","size",",","size",")","is","made","."]
code: def __init__(
      self, size, crop_type="center", padding=None, ignore_label=255
  ):
      self.size = size
      if isinstance(size, int):
          self.crop_h = size
          self.crop_w = size
      elif (
          isinstance(size, collections.Iterable)
          and len(size) == 2
          and isinstance(size[0], int)
          and isinstance(size[1], int)
          and size[0] > 0
          and size[1] > 0
      ):
          self.crop_h = size[0]
          self.crop_w = size[1]
      else:
          raise (RuntimeError("crop size error.\n"))
      if crop_type == "center" or crop_type == "rand":
          self.crop_type = crop_type
      else:
          raise (RuntimeError("crop type error: rand | center\n"))
      if padding is None:
          self.padding = padding
      elif isinstance(padding, list):
          if all(isinstance(i, numbers.Number) for i in padding):
              self.padding = padding
          else:
              raise (
                  RuntimeError(
                      "padding in Crop() should be a number list\n"
                  )
              )
          if len(padding) != 3:
              raise (
                  RuntimeError("padding channel is not equal with 3\n")
              )
      else:
          raise (
              RuntimeError(
                  "padding in Crop() should be a number list\n"
              )
          )
      if isinstance(ignore_label, int):
          self.ignore_label = ignore_label
      else:
          raise (
              RuntimeError("ignore_label should be an integer number\n")
          )
  
imports: import random
  import math
  import numpy
  import numbers
  import collections
  import cv2
  import torch
  import time
label_desc: Use image node_id 1 to create a new Crop object from inherited base classes: object with example: obj = Crop(size, crop_type, padding, ignore_label)