code: def cascade_inference(
      model, image_left, image_right, iterations, cascades
  ):
      # check that image size is divisible by 16 * (2 ** (cascades - 1))
      for image in [image_left, image_right]:
          if image.shape[-2] % ((2 ** (cascades - 1))) != 0:
              raise ValueError(
                  f"image height is not divisible by {16 * (2 ** (cascades - 1))}. Image shape: {image.shape[-2]}"
              )
  
          if image.shape[-1] % ((2 ** (cascades - 1))) != 0:
              raise ValueError(
                  f"image width is not divisible by {16 * (2 ** (cascades - 1))}. Image shape: {image.shape[-2]}"
              )
  
      left_image_pyramid = [image_left]
      right_image_pyramid = [image_right]
      for idx in range(0, cascades - 1):
          ds_factor = int(2 ** (idx + 1))
          ds_shape = (
              image_left.shape[-2] // ds_factor,
              image_left.shape[-1] // ds_factor,
          )
          left_image_pyramid += F.interpolate(
              image_left,
              size=ds_shape,
              mode="bilinear",
              align_corners=True,
          ).unsqueeze(0)
          right_image_pyramid += F.interpolate(
              image_right,
              size=ds_shape,
              mode="bilinear",
              align_corners=True,
          ).unsqueeze(0)
  
      flow_init = None
      for left_image, right_image in zip(
          reversed(left_image_pyramid), reversed(right_image_pyramid)
      ):
          flow_pred = model(
              left_image, right_image, flow_init, num_iters=iterations
          )
          # flow pred is a list
          flow_init = flow_pred[-1]
  
      return flow_init
  
file_path: vision/references/depth/stereo/cascade_evaluation.py
imports: import os
  import warnings
  import torch
  import torchvision
  import torchvision.prototype.models.depth.stereo
  import utils
  from torch.nn import functional
  from train import make_eval_loader
  from utils.metrics import AVAILABLE_METRICS
  from visualization import make_prediction_image_side_to_side
label_desc: Use image node_id 2 for calling a global function with example usage: cascade_inference(model, image_left, image_right, iterations, cascades) and returns: flow_init