import numpy as np
import megengine as mge
import megengine.functional as F
import megengine.module as M
import math
from config import config
from backbone.resnet50 import ResNet50
from module.generate_anchors import generate_anchors
from det_opr.bbox_opr import bbox_transform_inv_opr, box_overlap_opr
from det_opr.utils import get_padded_tensor
from rpn_anchor_target_opr import rpn_anchor_target_opr
from det_opr.loss_opr import sigmoid_cross_entropy_retina, smooth_l1_loss_retina, iou_l1_loss
import pdb

class RetinaNetAnchorV2(M.Module):
    def __init__(self):
        super().__init__()
    
    def generate_anchors_opr(self, fm_3x3, fm_stride,
        anchor_scales=(8, 16, 32, 64, 128), 
        anchor_ratios=(1, 2, 3), base_size = 4):

        np_anchors = generate_anchors(
            base_size=base_size,
            ratios=np.array(anchor_ratios),
            scales=np.array(anchor_scales))
        device = fm_3x3.device
        anchors = 
mge.tensor(np_anchors)