code: def _process_crop(
      self,
      image: np.ndarray,
      crop_box: List[int],
      crop_layer_idx: int,
      orig_size: Tuple[int, ...],
  ) -> MaskData:
      # Crop the image and calculate embeddings
      x0, y0, x1, y1 = crop_box
      cropped_im = image[y0:y1, x0:x1, :]
      cropped_im_size = cropped_im.shape[:2]
      self.predictor.set_image(cropped_im)
  
      # Get points for this crop
      points_scale = np.array(cropped_im_size)[None, ::-1]
      points_for_image = self.point_grids[crop_layer_idx] * points_scale
  
      # Generate masks for this crop in batches
      data = MaskData()
      for (points,) in batch_iterator(
          self.points_per_batch, points_for_image
      ):
          batch_data = self._process_batch(
              points, cropped_im_size, crop_box, orig_size
          )
          data.cat(batch_data)
          del batch_data
      self.predictor.reset_image()
  
      # Remove duplicates within this crop.
      keep_by_nms = nms(
          data["boxes"].cast("float32"),
          scores=data["iou_preds"],
          # category_idxs=paddle.zeros([len(data["boxes"])]),  # categories
          iou_threshold=self.box_nms_thresh,
      )
      data.filter(keep_by_nms)
  
      # Return to the original image frame
      data["boxes"] = uncrop_boxes_xyxy(data["boxes"], crop_box)
      data["points"] = uncrop_points(data["points"], crop_box)
      data["crop_boxes"] = paddle.to_tensor(
          [crop_box for _ in range(len(data["rles"]))]
      )
      return data
  
file_path: PaddleSeg/contrib/SegmentAnything/segment_anything/automatic_mask_generator.py
imports: import numpy
  import paddle
  from paddle.vision.ops import nms
  from typing import Any, Dict, List, Optional, Tuple
  from .modeling import Sam
  from .predictor import SamPredictor
  from .utils.amg import MaskData, area_from_rle, batch_iterator, batched_mask_to_box, box_xyxy_to_xywh, build_all_layer_point_grids, calculate_stability_score, coco_encode_rle, generate_crop_boxes, is_box_near_crop_edge, mask_to_rle_paddle, remove_small_regions, rle_to_mask, uncrop_boxes_xyxy, uncrop_masks, uncrop_points
label_desc: Use image node_id 4 for calling the SamAutomaticMaskGenerator obj's underlying member method code with example usage: obj._process_crop(image, crop_box, crop_layer_idx, orig_size) and returns: data