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 __call__(self, image, label):
      h, w = label.shape
  
      pad_h = max(self.crop_h - h, 0)
      pad_w = max(self.crop_w - w, 0)
      pad_h_half = int(pad_h / 2)
      pad_w_half = int(pad_w / 2)
      if pad_h > 0 or pad_w > 0:
          if self.padding is None:
              raise (
                  RuntimeError(
                      "segtransform.Crop() need padding while padding argument is None\n"
                  )
              )
          image = cv2.copyMakeBorder(
              image,
              pad_h_half,
              pad_h - pad_h_half,
              pad_w_half,
              pad_w - pad_w_half,
              cv2.BORDER_CONSTANT,
              value=self.padding,
          )
          label = cv2.copyMakeBorder(
              label,
              pad_h_half,
              pad_h - pad_h_half,
              pad_w_half,
              pad_w - pad_w_half,
              cv2.BORDER_CONSTANT,
              value=self.ignore_label,
          )
      h, w = label.shape
      raw_label = label
      raw_image = image
  
      if self.crop_type == "rand":
          h_off = random.randint(0, h - self.crop_h)
          w_off = random.randint(0, w - self.crop_w)
      else:
          h_off = int((h - self.crop_h) / 2)
          w_off = int((w - self.crop_w) / 2)
      image = image[
          h_off : h_off + self.crop_h, w_off : w_off + self.crop_w
      ]
      label = label[
          h_off : h_off + self.crop_h, w_off : w_off + self.crop_w
      ]
      raw_pos_num = np.sum(raw_label == 1)
      pos_num = np.sum(label == 1)
      crop_cnt = 0
      while pos_num < 0.85 * raw_pos_num and crop_cnt <= 30:
          image = raw_image
          label = raw_label
          if self.crop_type == "rand":
              h_off = random.randint(0, h - self.crop_h)
              w_off = random.randint(0, w - self.crop_w)
          else:
              h_off = int((h - self.crop_h) / 2)
              w_off = int((w - self.crop_w) / 2)
          image = image[
              h_off : h_off + self.crop_h, w_off : w_off + self.crop_w
          ]
          label = label[
              h_off : h_off + self.crop_h, w_off : w_off + self.crop_w
          ]
          raw_pos_num = np.sum(raw_label == 1)
          pos_num = np.sum(label == 1)
          crop_cnt += 1
      if crop_cnt >= 50:
          image = cv2.resize(
              raw_image,
              (self.size[0], self.size[0]),
              interpolation=cv2.INTER_LINEAR,
          )
          label = cv2.resize(
              raw_label,
              (self.size[0], self.size[0]),
              interpolation=cv2.INTER_NEAREST,
          )
  
      if image.shape != (self.size[0], self.size[0], 3):
          image = cv2.resize(
              image,
              (self.size[0], self.size[0]),
              interpolation=cv2.INTER_LINEAR,
          )
          label = cv2.resize(
              label,
              (self.size[0], self.size[0]),
              interpolation=cv2.INTER_NEAREST,
          )
  
      return image, label
  
imports: import random
  import math
  import numpy
  import numbers
  import collections
  import cv2
  import torch
  import time
label_desc: Use image node_id 2 for calling the Crop obj's underlying member method code with example usage: obj.__call__(image, label) and returns: image,  label