code: def infer_type_with_broadcast(typea, typeb, primitive_type):
      """
      Given 2 primitive types `typea` and `typeb`, and their promotion `primitive_type`,
      return the type after broadcast
      """
  
      # broadcast
      if not types.is_tensor(typea) and not types.is_tensor(typeb):
          # both typea and typeb are not tensors
          return primitive_type
      if types.is_tensor(typea) and not types.is_tensor(typeb):
          # a is tensor, b is not
          return types.tensor(primitive_type, typea.get_shape())
      if not types.is_tensor(typea) and types.is_tensor(typeb):
          # a is not tensor, b is
          return types.tensor(primitive_type, typeb.get_shape())
  
      # both a, b are tensors
      shapea = list(typea.get_shape())
      shapeb = list(typeb.get_shape())
      ret_shape = broadcast_shapes(shapea, shapeb)
      return types.tensor(primitive_type, ret_shape)
  
imports: import math
  import numbers
  from typing import List, Tuple
  import numpy
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import Var, get_new_symbol, types
  from coremltools.converters.mil.mil.ops.defs.iOS15.elementwise_unary import cast
  from coremltools.converters.mil.mil.types import builtin_to_string, promote_dtypes
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic
label_desc: Use image node_id 2 for calling a global function with example usage: infer_type_with_broadcast(typea, typeb, primitive_type) and returns: types, primitive_type, types, types