@classmethod
def _compute_broadcast_kwargs(cls, shape1, shape2):
    """
        Given two shapes, compute the broadcast shape, along with the keywords
        needed to produce BroadcastArrays with arrays of given shape.

        Parameters
        ----------
        shape1 : iterable
        shape2 : iterable
            The two shapes to broadcast against one another.

        Returns
        -------
        full_shape : iterable
            The full broadcast shape.
        broadcast_kwargs1 : dict
        broadcast_kwargs2 : dict
            Keywords which are suitably passed through to a BroadcastArray
            to take the original array, and broadcast to the full broadcast
            shape.

        """
    full_shape = cls._compute_broadcast_shape(shape1, shape2)
    bcast_kwargs1 = {'broadcast': {}, 'leading_shape': ()}
    bcast_kwargs2 = {'broadcast': {}, 'leading_shape': ()}
    ndim_diff = len(shape1) - len(shape2)
    s1_offset = s2_offset = 0
    if ndim_diff > 0:
        s2_offset = ndim_diff
        bcast_kwargs2['leading_shape'] = full_shape[:s2_offset]
    elif len(shape1) < len(shape2):
        s1_offset = abs(ndim_diff)
        bcast_kwargs1['leading_shape'] = full_shape[:s1_offset]
    for ax, (full, s1) in enumerate(zip(full_shape[s1_offset:], shape1)):
        if full != s1:
            bcast_kwargs1['broadcast'][ax] = full
    for ax, (full, s2) in enumerate(zip(full_shape[s2_offset:], shape2)):
        if full != s2:
            bcast_kwargs2['broadcast'][ax] = full
    return full_shape, bcast_kwargs1, bcast_kwargs2
