import io
import pickle

import numpy as np

import megengine.functional as F
import megengine.module as M
import megengine.utils.comp_graph_tools as cgtools
from megengine.core._trace_option import set_symbolic_shape
from megengine.jit import trace
from megengine.traced_module import trace_module

set_symbolic_shape(True)


class Main(M.Module):
    def forward(self, x):
        return x


class PreProcess(M.Module):
    def __init__(self):
        super().__init__()
        self.I = F.ones((1,))
        self.M = F.zeros((1,))

    def forward(self, data, idx, roi):
        N, H, W, C = data.shape
        xmax = roi[:, 1, 0]
        xmin = roi[:, 0, 0]
        ymax = roi[:, 1, 1]
        ymin = roi[:, 0, 1]
        scale = 
F.maximum((xmax - xmin) / W, (ymax - ymin) / H)