def ortho_init(scale=1.0):

    def _ortho_init(shape, dtype, partition_info=None):
        shape = tuple(shape)
        if (len(shape) == 2):
            flat_shape = shape
        elif (len(shape) == 4):
            flat_shape = (np.prod(shape[:(- 1)]), shape[(- 1)])
        else:
            raise NotImplementedError
        a = np.random.normal(0.0, 1.0, flat_shape)
        (u, _, v) = np.linalg.svd(a, full_matrices=False)
        q = (u if (u.shape == flat_shape) else v)
        q = q.reshape(shape)
        return (scale * q[:shape[0], :shape[1]]).astype(np.float32)
    return _ortho_init
def ortho_init(scale=1.0):

    def _ortho_init(shape, dtype, partition_info=None):
        shape = tuple(shape)
        if (len(shape) == 2):
            flat_shape = shape
        elif (len(shape) == 4):
            flat_shape = (np.prod(shape[:(- 1)]), shape[(- 1)])
        else:
            raise NotImplementedError
        a = np.random.normal(0.0, 1.0, flat_shape)
        (u, _, v) = np.linalg.svd(a, full_matrices=False)
        q = (u if (u.shape == flat_shape) else v)
        q = q.reshape(shape)
        return (scale * q[:shape[0], :shape[1]]).astype(np.float32)
    return _ortho_init