code: def transform_pattern(pattern):
      is_sub, is_first_input = _get_is_sub_and_is_first_input(pattern)
      linear_bias, bias, Dout = _get_linear_bias_bias_Dout(
          pattern, is_first_input
      )
      bias = np.reshape(bias, (Dout,))
  
      if is_sub and is_first_input:
          bias = -bias
      if is_sub and not is_first_input:
          linear_bias = -linear_bias
  
      new_bias = linear_bias + bias
  
      # compute the new weight
      if is_sub and not is_first_input:
          new_weight = -pattern.linear.weight.val
      else:
          new_weight = pattern.linear.weight.val
  
      # create a new linear op with the new weight, bias value, copying rest of the attributes
      out_name = pattern.add_or_sub.outputs[0].name
      linear_kargs = {
          "weight": new_weight,
          "bias": new_bias,
          "name": out_name,
          "before_op": pattern.linear,
      }
  
      linear_kargs.update(
          {
              k: v
              for k, v in pattern.linear.inputs.items()
              if k not in ["weight", "bias"]
          }
      )
  
      x = mb.linear(**linear_kargs)
  
      pattern.add_or_sub.enclosing_block.replace_uses_of_var_after_op(
          anchor_op=pattern.add_or_sub,
          old_var=pattern.add_or_sub.outputs[0],
          new_var=x,
      )
      # Remove all the ops at once
      pattern.block.remove_ops(pattern.op_list())
  
file_path: coremltools/coremltools/converters/mil/experimental/passes/generic_linear_bias_fusion.py
imports: import os
  import numpy
  from coremltools.converters.mil import Builder
  from coremltools.converters.mil.experimental.passes.generic_pass_infrastructure import register_generic_pass
  from coremltools.converters.mil.mil import get_new_symbol
label_desc: Use image node_id 4 for calling a global function with example usage: transform_pattern(pattern) without return types