code: def _broadcast_shapes(
      shape1: Tuple[int, ...], shape2: Tuple[int, ...]
  ) -> Tuple[int, ...]:
      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 BroadcastError()
          i = i - 1
      return tuple(shape)
  
imports: from hypothesis import assume, strategies
  from typing import Tuple
  from functools import lru_cache
  import math
  import numpy
  import ivy
  from .None import array_helpers, number_helpers, dtype_helpers
  from ..pipeline_helper import WithBackendContext
  from ivy.functional.ivy.layers import _deconv_length
  from ..globals import mod_backend
label_desc: Use image node_id 4 for calling a global function with example usage: _broadcast_shapes(shape1, shape2) and returns: tuple