code: def _is_scalar(pattern):
      # for the scalar case, the scalar can be either
      # 1. a python int/float
      # 2. a 0d numpy array
      # 3. a 1d numpy array with shape (1,)
      scale_var = (
          pattern.scale.x
          if pattern.scale.x.val is not None
          else pattern.scale.y
      )
      scale = scale_var.val
      is_scalar = True
      if isinstance(scale, np.ndarray):
          if scale.shape == ():
              scale = scale.tolist()
          elif scale.shape == (1) or scale.shape == (1,):
              scale = scale[0]
          else:
              is_scalar = False
  
      return is_scalar
  
file_path: coremltools/coremltools/converters/mil/experimental/passes/generic_conv_scale_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
label_desc: Use image node_id 2 for calling a global function with example usage: _is_scalar(pattern) and returns: is_scalar