code: def aug_inference(
      model,
      model_hard,
      im,
      ori_shape,
      transforms,
      scales=1.0,
      flip_horizontal=False,
      flip_vertical=False,
      is_slide=False,
      stride=None,
      crop_size=None,
  ):
      """
      Infer with augmentation.
  
      Args:
          model (paddle.nn.Layer): model to get logits of image.
          im (Tensor): the input image.
          ori_shape (list): Origin shape of image.
          transforms (list): Transforms for image.
          scales (float|tuple|list):  Scales for resize. Default: 1.
          flip_horizontal (bool): Whether to flip horizontally. Default: False.
          flip_vertical (bool): Whether to flip vertically. Default: False.
          is_slide (bool): Whether to infer by sliding wimdow. Default: False.
          crop_size (tuple|list). The size of sliding window, (w, h). It should be probided if is_slide is True.
          stride (tuple|list). The size of stride, (w, h). It should be probided if is_slide is True.
  
      Returns:
          Tensor: Prediction of image with shape (1, 1, h, w) is returned.
      """
      if isinstance(scales, float):
          scales = [scales]
      elif not isinstance(scales, (tuple, list)):
          raise TypeError(
              "`scales` expects float/tuple/list type, but received {}".format(
                  type(scales)
              )
          )
      final_logit = 0
      h_input, w_input = im.shape[-2], im.shape[-1]
      flip_comb = flip_combination(flip_horizontal, flip_vertical)
      for scale in scales:
          h = int(h_input * scale + 0.5)
          w = int(w_input * scale + 0.5)
          im = F.interpolate(im, (h, w), mode="bilinear")
          for flip in flip_comb:
              im_flip = tensor_flip(im, flip)
              logit = inference(
                  model,
                  model_hard,
                  im_flip,
                  is_slide=is_slide,
                  crop_size=crop_size,
                  stride=stride,
              )
              logit = tensor_flip(logit, flip)
              logit = F.interpolate(
                  logit, (h_input, w_input), mode="bilinear"
              )
  
              #             logit = F.softmax(logit, axis=1)
              final_logit = final_logit + logit
  
      return final_logit
  
file_path: PaddleSeg/contrib/AutoNUE/core/infer_ensemble_three.py
imports: import collections.abc
  from itertools import combinations
  import numpy
  import paddle
  import paddle.nn.functional
label_desc: Use image node_id 6 for calling a global function with example usage: aug_inference(model, model_hard, im, ori_shape, transforms, scales, flip_horizontal, flip_vertical, is_slide, stride, crop_size) and returns: final_logit