class_docstr: Currently we only use it to infer caffe shape, we use tensorflow engine
  to infer tensorflow op shapes, since tensorflow has too many ops.
class_docstr_tok: ["Currently","we","only","use","it","to","infer","caffe","shape",",","we","use","tensorflow","engine","to","infer","tensorflow","op","shapes",",","since","tensorflow","has","too","many","ops","."]
code: def infer_shape_nearest_neighbor(self, op):
      input_shape = self._output_shape_cache[op.input[0]]
      height_scale = ConverterUtil.get_arg(
          op, MaceKeyword.mace_height_scale_str
      ).f
      width_scale = ConverterUtil.get_arg(
          op, MaceKeyword.mace_width_scale_str
      ).f
      if ConverterUtil.data_format(op) == DataFormat.NCHW:
          output_shape = [
              input_shape[0],
              input_shape[1],
              int(input_shape[2] * height_scale),
              int(input_shape[3] * width_scale),
          ]
      elif ConverterUtil.data_format(op) == DataFormat.NHWC:
          output_shape = [
              input_shape[0],
              int(input_shape[2] * height_scale),
              int(input_shape[3] * width_scale),
              input_shape[3],
          ]
      else:
          output_shape = []
          mace_check(
              False,
              "format %s is not supported"
              % ConverterUtil.data_format(op),
          )
      self.add_output_shape(op, [output_shape])
  
imports: import math
  import numpy
  import six
  from transform.transformer import Transformer
  from transform.base_converter import DataFormat
  from transform.base_converter import MaceOp
  from transform.base_converter import MaceKeyword
  from transform.base_converter import ConverterUtil
  from utils.util import mace_check
label_desc: Use image node_id 18 for calling the ShapeInference obj's underlying member method code with example usage: obj.infer_shape_nearest_neighbor(op) without return types