code: def fuse_model(m):
      prev_previous_type = nn.Identity()
      prev_previous_name = ""
      previous_type = nn.Identity()
      previous_name = ""
      for name, module in m.named_modules():
          if (
              prev_previous_type == nn.Conv2d
              and previous_type == nn.BatchNorm2d
              and type(module) == nn.ReLU
          ):
              # print("FUSED ", prev_previous_name, previous_name, name)
              torch.quantization.fuse_modules(
                  m,
                  [prev_previous_name, previous_name, name],
                  inplace=True,
              )
          elif (
              prev_previous_type == nn.Conv2d
              and previous_type == nn.BatchNorm2d
          ):
              # print("FUSED ", prev_previous_name, previous_name)
              torch.quantization.fuse_modules(
                  m, [prev_previous_name, previous_name], inplace=True
              )
          # elif previous_type == nn.Conv2d and type(module) == nn.ReLU:
          #    print("FUSED ", previous_name, name)
          #    torch.quantization.fuse_modules(m, [previous_name, name], inplace=True)
  
          prev_previous_type = previous_type
          prev_previous_name = previous_name
          previous_type = type(module)
          previous_name = name
  
file_path: carefree-learn/cflearn/api/cv/third_party/midas/core/midas_net_custom.py
imports: import torch
  import torch.nn
  from .base_model import BaseModel
  from .blocks import FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder
label_desc: Use image node_id 1 for calling a global function with example usage: fuse_model(m) without return types