@classmethod
def _broadcast_numpy_array(cls, array, broadcast_dict, leading_shape=()):
    """Broadcast a numpy array according to the broadcast_dict."""
    from numpy.lib.stride_tricks import as_strided
    shape = cls._shape_from_broadcast_dict(array.shape, broadcast_dict)
    shape = tuple(leading_shape) + shape
    strides = [0] * len(leading_shape) + list(array.strides)
    for broadcast_axis in broadcast_dict:
        strides[broadcast_axis + len(leading_shape)] = 0
    strided = as_strided(array, shape=tuple(shape), strides=tuple(strides))
    strided.flags.writeable = False
    return strided
