(a)
return out
Given a list (tuple, array) of arrays, this method computes their outer
    product. If the dimension of the input arrays is larger than one, the
    product is formed across the first dimension; all other dimensions must
    coincide in size.

    Examples:
    n_outer([np.ones(4), np.ones(5)]).shape == (4, 5)
    n_outer([np.ones(4), np.ones(5), np.ones(6)]).shape == (4, 5, 6)
    n_outer([np.ones(4, 3, 7), np.ones(5, 3, 7)]).shape == (4, 5, 3, 7)
Given a list (tuple, array) of arrays, this method computes their outer
    product. If the dimension of the input arrays is larger than one, the
    product is formed across the first dimension; all other dimensions must
    coincide in size.
Given a list ( tuple array ) of arrays this method computes their outer product . If the dimension of the input arrays is larger than one the product is formed across the first dimension ; all other dimensions must coincide in size .
def n_outer(a):
    """Given a list (tuple, array) of arrays, this method computes their outer
    product. If the dimension of the input arrays is larger than one, the
    product is formed across the first dimension; all other dimensions must
    coincide in size.

    Examples:
    n_outer([np.ones(4), np.ones(5)]).shape == (4, 5)
    n_outer([np.ones(4), np.ones(5), np.ones(6)]).shape == (4, 5, 6)
    n_outer([np.ones(4, 3, 7), np.ones(5, 3, 7)]).shape == (4, 5, 3, 7)
    """
    # <https://stackoverflow.com/a/45376730/353337>
    d = len(a)

    # If the elements are more than one-dimensional, assert that the extra
    # dimensions are all equal.
    s0 = a[0].shape
    for arr in a:
        assert s0[1:] == arr.shape[1:]

    out = a[0]
    for k in range(1, d):
        # Basically outer products. Checkout `np.outer`'s implementation for
        # comparison.
        out = np.multiply(
            # Insert a newaxis after k `:`
            out[(slice(None),) * k + (np.newaxis,)],
            # Insert a newaxis at the beginning
            a[k][np.newaxis],
        )
    return out
def n_outer ( a ) : # <https://stackoverflow.com/a/45376730/353337> d = len ( a ) # If the elements are more than one-dimensional, assert that the extra # dimensions are all equal. s0 = a [ 0 ] . shape for arr in a : assert s0 [ 1 : ] == arr . shape [ 1 : ] out = a [ 0 ] for k in range ( 1 , d ) : # Basically outer products. Checkout `np.outer`'s implementation for # comparison. out = np . multiply ( # Insert a newaxis after k `:` out [ ( slice ( None ) , ) * k + ( np . newaxis , ) ] , # Insert a newaxis at the beginning a [ k ] [ np . newaxis ] , ) return out