(self, x, boxes)
return result
Arguments:
            x (list[Tensor]): feature maps for each level
            boxes (list[BoxList]): boxes to be used to perform the pooling operation.
        Returns:
            result (Tensor)
Arguments:
            x (list[Tensor]): feature maps for each level
            boxes (list[BoxList]): boxes to be used to perform the pooling operation.
        Returns:
            result (Tensor)
Arguments : x ( list [ Tensor ] ) : feature maps for each level boxes ( list [ BoxList ] ) : boxes to be used to perform the pooling operation . Returns : result ( Tensor )
def forward(self, x, boxes):
        """
        Arguments:
            x (list[Tensor]): feature maps for each level
            boxes (list[BoxList]): boxes to be used to perform the pooling operation.
        Returns:
            result (Tensor)
        """
        num_levels = len(self.poolers)
        rois = self.convert_to_roi_format(boxes)
        if num_levels == 1:
            return self.poolers[0](x[0], rois)

        levels = self.map_levels(boxes)

        num_rois = len(rois)
        num_channels = x[0].shape[1]
        output_size = self.output_size[0]

        dtype, device = x[0].dtype, x[0].device
        result = torch.zeros(
            (num_rois, num_channels, output_size, output_size),
            dtype=dtype,
            device=device,
        )
        for level, (per_level_feature, pooler) in enumerate(zip(x, self.poolers)):
            idx_in_level = torch.nonzero(levels == level).squeeze(1)
            rois_per_level = rois[idx_in_level]
            if idx_in_level.numel() == 0:
                if num_rois == 0:
                    continue
                # create a roi and do one empty forward pass
                new_level = idx_in_level.new_tensor((0,))
                new_rois = rois[new_level]
                result[new_level] = result[new_level] \
                                    + pooler(per_level_feature, new_rois) * 0.0
            else:
                result[idx_in_level] = pooler(per_level_feature, rois_per_level)

        return result
def forward ( self , x , boxes ) : num_levels = len ( self . poolers ) rois = self . convert_to_roi_format ( boxes ) if num_levels == 1 : return self . poolers [ 0 ] ( x [ 0 ] , rois ) levels = self . map_levels ( boxes ) num_rois = len ( rois ) num_channels = x [ 0 ] . shape [ 1 ] output_size = self . output_size [ 0 ] dtype , device = x [ 0 ] . dtype , x [ 0 ] . device result = torch . zeros ( ( num_rois , num_channels , output_size , output_size ) , dtype = dtype , device = device , ) for level , ( per_level_feature , pooler ) in enumerate ( zip ( x , self . poolers ) ) : idx_in_level = torch . nonzero ( levels == level ) . squeeze ( 1 ) rois_per_level = rois [ idx_in_level ] if idx_in_level . numel ( ) == 0 : if num_rois == 0 : continue # create a roi and do one empty forward pass new_level = idx_in_level . new_tensor ( ( 0 , ) ) new_rois = rois [ new_level ] result [ new_level ] = result [ new_level ] + pooler ( per_level_feature , new_rois ) * 0.0 else : result [ idx_in_level ] = pooler ( per_level_feature , rois_per_level ) return result