code: def _try_get_upsample_factor(output_size):
      op = output_size
      # If the output has value, than the upsample op itself is derived from the upsample_1d op,
      # so we can just return scale factor 1 for that case
      if op.outputs[0].val is not None:
          assert op.outputs[0].val == 1.0
          return 1.0
  
      # output_size = [
      #       (torch.floor((input.size(i + 2).float() * torch.tensor(scale_factors[i], dtype=torch.float32)).float()))
      #        for i in range(dim)
      #    ]
      # source from : https://pytorch.org/docs/stable/_modules/torch/nn/functional.html#interpolate
      # We validation if we can trace all the way back to the original scale_factor
      # The whole sequence is mul(input_size, scale_factor) -> cast(fp32) -> floor() -> cast(int32)
  
      # 1. check if the output_size is type 'cast' with dtype 'int32'
      if op.op_type != "cast" or op.dtype.val != "int32":
          return None
  
      # 2. check if the op is type 'floor'
      op = op.x.op
      if op.op_type != "floor":
          return None
  
      # 3. check if the op is type 'cast' with dtype 'fp32'
      op = op.x.op
      if op.op_type != "cast" or op.dtype.val != "fp32":
          return None
  
      # 4. check if the op is type mul
      op = op.x.op
      if op.op_type != "mul":
          return None
  
      # we successfully trace back the original scale factor
      return np.float32(op.y.val)
  
file_path: coremltools/coremltools/converters/mil/frontend/torch/ssa_passes/torch_upsample_to_core_upsample.py
imports: import numpy
  from coremltools import _logger
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil.passes.graph_pass import AbstractGraphPass
  from coremltools.converters.mil.mil.passes.helper import block_context_manager
  from coremltools.converters.mil.mil.passes.pass_registry import register_pass
label_desc: Use image node_id 2 for calling a global function with example usage: _try_get_upsample_factor(output_size) and returns: np, int, None, None, None, None