code: def _broadcast_shapes(shape1, shape2):
      """Broadcasts `shape1` and `shape2`"""
      N1 = len(shape1)
      N2 = len(shape2)
      N = max(N1, N2)
      shape = [None for _ in range(N)]
      i = N - 1
      while i >= 0:
          n1 = N1 - N + i
          if N1 - N + i >= 0:
              d1 = shape1[n1]
          else:
              d1 = 1
          n2 = N2 - N + i
          if N2 - N + i >= 0:
              d2 = shape2[n2]
          else:
              d2 = 1
  
          if d1 == 1:
              shape[i] = d2
          elif d2 == 1:
              shape[i] = d1
          elif d1 == d2:
              shape[i] = d1
          else:
              raise Exception("Broadcast error")
  
          i = i - 1
  
      return tuple(shape)
  
imports: import numpy
  import hypothesis.extra.numpy
  from hypothesis import strategies
  from hypothesis.internal.floats import float_of
  from functools import reduce
  from operator import mul
  import sys
  import string
  import ml_dtypes
  import ivy_tests.test_ivy.helpers.globals
  from ..pipeline_helper import WithBackendContext
  import ivy_tests.test_ivy.helpers
  from ivy_tests.test_ivy.helpers.hypothesis_helpers.dtype_helpers import get_dtypes
  from .None import general_helpers
  from .None import dtype_helpers, number_helpers
  from ..globals import mod_backend
label_desc: Use image node_id 12 for calling a global function with example usage: _broadcast_shapes(shape1, shape2) and returns: tuple