def METHOD_NAME(x,
                        target,
                        angle=0,
                        translate=(0, 0),
                        scale=1,
                        shear=(0, 0),
                        hflip=False,
                        boxes_sample_prob=[],
                        scale_ratio=1.0):
    boxes_and_labels = [(target.bbox[i], target.extra_fields['labels'][i])
                        for i in range(len(target.bbox))
                        if random.random() < boxes_sample_prob[i]]
    boxes = [b_and_l[0] for b_and_l in boxes_and_labels]
    labels = [b_and_l[1] for b_and_l in boxes_and_labels]
    if random.random() < 0.5:
        angle *= -1
        translate = (-translate[0], -translate[1])
        shear = (-shear[0], -shear[1])
    height, width = x.shape[1], x.shape[2]
    x_crops = []
    boxes_crops = []
    boxes_new = []
    labels_new = []
    for i, box in enumerate(boxes):
        box_crop = scale_area(box, height, width, scale_ratio)
        y1, x1, y2, x2 = box_crop.long()
        x_crop = x[:, x1:x2, y1:y2]
        boxes_crops.append(box_crop)
        if x1 >= x2 or y1 >= y2:
            x_crops.append(x_crop)
            continue
        if hflip:
            x_crop = x_crop.flip(-1)
        elif translate[0] + translate[1] != 0:
            offset_y = (y2 + translate[0]).clamp(0, width).long().tolist() - y2
            offset_x = (x2 + translate[1]).clamp(0,
                                                 height).long().tolist() - x2
            if offset_x != 0 or offset_y != 0:
                offset = [offset_y, offset_x]
                boxes_new.append(box + torch.Tensor(offset * 2))
                labels_new.append(labels[i])
        else:
            x_crop = transforms.functional.to_pil_image(x_crop.cpu())
            try:
                x_crop = transforms.functional.affine(
                    x_crop,
                    angle,
                    translate,
                    scale,
                    shear,
                    resample=2,
                    fillcolor=tuple([int(i) for i in pixel_mean]))
            except Exception:
                x_crop = transforms.functional.affine(
                    x_crop,
                    angle,
                    translate,
                    scale,
                    shear,
                    interpolation=2,
                    fill=tuple([int(i) for i in pixel_mean]))
            x_crop = transforms.functional.to_tensor(x_crop).to(x.device)
        x_crops.append(x_crop)
    y = _transform(x, x_crops, boxes_crops, translate)
    if translate[0] + translate[1] != 0 and len(boxes_new) > 0:
        target.bbox = torch.cat((target.bbox, torch.stack(boxes_new)))
        target.extra_fields['labels'] = torch.cat(
            (target.extra_fields['labels'], torch.Tensor(labels_new).long()))
    return y, target