code: def forward_backward_consistency_check(
      fwd_flow, bwd_flow, alpha=0.01, beta=0.5
  ):
      # fwd_flow, bwd_flow: [B, 2, H, W]
      # alpha and beta values are following UnFlow
      # (https://arxiv.org/abs/1711.07837)
      assert fwd_flow.dim() == 4 and bwd_flow.dim() == 4
      assert fwd_flow.size(1) == 2 and bwd_flow.size(1) == 2
      flow_mag = torch.norm(fwd_flow, dim=1) + torch.norm(
          bwd_flow, dim=1
      )  # [B, H, W]
  
      warped_bwd_flow = flow_warp(bwd_flow, fwd_flow)  # [B, 2, H, W]
      warped_fwd_flow = flow_warp(fwd_flow, bwd_flow)  # [B, 2, H, W]
  
      diff_fwd = torch.norm(
          fwd_flow + warped_bwd_flow, dim=1
      )  # [B, H, W]
      diff_bwd = torch.norm(bwd_flow + warped_fwd_flow, dim=1)
  
      threshold = alpha * flow_mag + beta
  
      fwd_occ = (diff_fwd > threshold).float()  # [B, H, W]
      bwd_occ = (diff_bwd > threshold).float()
  
      return fwd_occ, bwd_occ
  
imports: import sys
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import PIL.Image
  import torch
  import torch.nn.functional
  import torchvision.transforms
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
  from diffusers.image_processor import VaeImageProcessor
  from diffusers.models import AutoencoderKL, ControlNetModel, UNet2DConditionModel
  from diffusers.models.attention_processor import Attention, AttnProcessor
  from diffusers.pipelines.controlnet.multicontrolnet import MultiControlNetModel
  from diffusers.pipelines.controlnet.pipeline_controlnet_img2img import StableDiffusionControlNetImg2ImgPipeline
  from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
  from diffusers.schedulers import KarrasDiffusionSchedulers
  from diffusers.utils import BaseOutput, deprecate, logging
  from diffusers.utils.torch_utils import is_compiled_module, randn_tensor
  from gmflow.gmflow import GMFlow
  from utils.utils import InputPadder
label_desc: Use image node_id 4 for calling a global function with example usage: forward_backward_consistency_check(fwd_flow, bwd_flow, alpha, beta) and returns: fwd_occ,  bwd_occ