code: def truncate_reg_channel(val, num_classes=81):
      # bias
      if val.dim() == 1:
          # fc_reg | rpn_reg
          if val.size(0) % num_classes == 0:
              new_val = val.reshape(num_classes, -1)[: num_classes - 1]
              new_val = new_val.reshape(-1)
          # agnostic
          else:
              new_val = val
      # weight
      else:
          out_channels, in_channels = val.shape[:2]
          # fc_reg | rpn_reg
          if out_channels % num_classes == 0:
              new_val = val.reshape(
                  num_classes, -1, in_channels, *val.shape[2:]
              )[1:]
              new_val = new_val.reshape(-1, *val.shape[1:])
          # agnostic
          else:
              new_val = val
  
      return new_val
  
file_path: mmdetection/tools/model_converters/upgrade_model_version.py
imports: import argparse
  import re
  import tempfile
  from collections import OrderedDict
  import torch
  from mmengine import Config
label_desc: Use image node_id 5 for calling a global function with example usage: truncate_reg_channel(val, num_classes) and returns: new_val