code: def var_constraints(pattern):
      bias_value = _get_bias_var(pattern).val
      rank = pattern.conv.x.rank
      is_bias_scalar = (
          True if not isinstance(bias_value, np.ndarray) else False
      )
      old_bias = pattern.conv.inputs.get("bias", None)
      old_bias_value = (
          old_bias.val
          if old_bias is not None and old_bias.val is not None
          else None
      )
  
      passed = True
      passed = passed and isinstance(
          bias_value, (np.ndarray, np.generic)
      )
      passed = passed and rank is not None
      passed = passed and (rank == 3 or rank == 4 or rank == 5)
  
      # check compatibility of bias value with the rank of the conv op
      # either bias value should be a scalar or:
      # rank=3 ==> (B,C,D), which means bias must be (1,C,1) or (C,1)
      # rank=4 ==> (B,C,D1,D2), which means bias must be (1,C,1,1) or (C,1,1)
      # rank=5 ==> (B,C,D1,D2,D3), which means bias must be (1,C,1,1,1) or (C,1,1,1)
      if not is_bias_scalar:
          # check that there is at most one dimension in the shape that is not 1
          passed = passed and len(np.squeeze(bias_value).shape) <= 1
          # check that addition is not happening on the batch dimension
          passed = passed and (
              len(bias_value) != rank or bias_value.shape[0] == 1
          )
          # check that last rank-2 entries in the shape vector are all 1s
          passed = (
              passed and np.prod(bias_value.shape[-(rank - 2) :]) == 1
          )
  
      bias_value = (
          np.array([bias_value])
          if is_bias_scalar
          else np.squeeze(bias_value)
      )
  
      passed = passed and (
          old_bias is not None
          or np.prod(bias_value.shape) != 1
          or pattern.conv.weight.val is not None
      )
  
      if old_bias is not None:
          try:
              new_bias_value = old_bias_value + bias_value
          except:
              return False
  
      return passed
  
file_path: coremltools/coremltools/converters/mil/experimental/passes/generic_conv_bias_fusion.py
imports: import os
  import numpy
  from coremltools import _logger
  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 types
label_desc: Use image node_id 2 for calling a global function with example usage: var_constraints(pattern) and returns: passed, False