class_docstr: Multi-size Segmentation Evaluator
class_docstr_tok: ["Multi-size","Segmentation","Evaluator"]
code: def __call__(self, image):
      # only single image is supported for evaluation
      image = image.expand_dims(0)
      batch, _, h, w = image.shape
      assert batch == 1
      base_size = self.base_size
      crop_size = self.crop_size
      stride_rate = 2.0 / 3.0
      stride = int(crop_size * stride_rate)
      scores = mx.nd.zeros(
          (batch, self.nclass, h, w), ctx=image.context
      )
      for scale in self.scales:
          long_size = int(math.ceil(base_size * scale))
          if h > w:
              height = long_size
              width = int(1.0 * w * long_size / h + 0.5)
              short_size = width
          else:
              width = long_size
              height = int(1.0 * h * long_size / w + 0.5)
              short_size = height
          # resize image to current size
          cur_img = _resize_image(image, height, width)
          if long_size <= crop_size:
              pad_img = _pad_image(cur_img, crop_size)
              outputs = self.flip_inference(pad_img)
              outputs = _crop_image(outputs, 0, height, 0, width)
          else:
              if short_size < crop_size:
                  # pad if needed
                  pad_img = _pad_image(cur_img, crop_size)
              else:
                  pad_img = cur_img
              _, _, ph, pw = pad_img.shape
              assert ph >= height and pw >= width
              # grid forward and normalize
              h_grids = (
                  int(math.ceil(1.0 * (ph - crop_size) / stride)) + 1
              )
              w_grids = (
                  int(math.ceil(1.0 * (pw - crop_size) / stride)) + 1
              )
              outputs = mx.nd.zeros(
                  (batch, self.nclass, ph, pw), ctx=image.context
              )
              count_norm = mx.nd.zeros(
                  (batch, 1, ph, pw), ctx=image.context
              )
              # grid evaluation
              for idh in range(h_grids):
                  for idw in range(w_grids):
                      h0 = idh * stride
                      w0 = idw * stride
                      h1 = min(h0 + crop_size, ph)
                      w1 = min(w0 + crop_size, pw)
                      crop_img = _crop_image(pad_img, h0, h1, w0, w1)
                      # pad if needed
                      pad_crop_img = _pad_image(crop_img, crop_size)
                      output = self.flip_inference(pad_crop_img)
                      outputs[:, :, h0:h1, w0:w1] += _crop_image(
                          output, 0, h1 - h0, 0, w1 - w0
                      )
                      count_norm[:, :, h0:h1, w0:w1] += 1
              assert (count_norm == 0).sum() == 0
              outputs = outputs / count_norm
              outputs = outputs[:, :, :height, :width]
  
          score = _resize_image(outputs, h, w)
          scores += score
  
      return scores
  
imports: import math
  import warnings
  import numpy
  import mxnet
  from mxnet.ndarray import NDArray
  from mxnet.gluon.nn import HybridBlock
  from ..utils.parallel import parallel_apply
  from .resnetv1b import resnet18_v1b, resnet34_v1b, resnet50_v1s, resnet101_v1s, resnet152_v1s
  from .resnest import resnest50, resnest101, resnest200, resnest269
  from ..utils.parallel import tuple_map
label_desc: Use image node_id 3 for calling the MultiEvalModel obj's underlying member method code with example usage: obj.__call__(image) and returns: scores