def _solve(self, rhs, adjoint=False, adjoint_arg=False):
    if adjoint_arg:
        rhs = linalg.adjoint(rhs)
    batch_shape = array_ops.concat([array_ops.ones_like(self.batch_shape_tensor()), [1, 1]], 0)
    rhs += array_ops.zeros(batch_shape, dtype=rhs.dtype.base_dtype)
    output = _rotate_last_dim(rhs, rotate_right=True)
    output = output[(array_ops.newaxis, ...)]
    for operator in self.operators[:(- 1)]:
        if adjoint:
            operator_dimension = operator.range_dimension_tensor()
        else:
            operator_dimension = operator.domain_dimension_tensor()
        output = _unvec_by(output, operator_dimension)
        output = array_ops.matrix_transpose(output)
        output = operator.solve(output, adjoint=adjoint, adjoint_arg=False)
        output = array_ops.matrix_transpose(output)
        output = _rotate_last_dim(output, rotate_right=False)
        output = _vec(output)
        output = _rotate_last_dim(output, rotate_right=True)
    output = self.operators[(- 1)].solvevec(output, adjoint=adjoint)
    output = _rotate_last_dim(output, rotate_right=False)
    output = _vec(output)
    output = _rotate_last_dim(output, rotate_right=False)
    if rhs.shape.is_fully_defined():
        column_dim = rhs.shape[(- 1)]
        broadcast_batch_shape = common_shapes.broadcast_shape(rhs.shape[:(- 2)], self.batch_shape)
        if adjoint:
            matrix_dimensions = [self.domain_dimension, column_dim]
        else:
            matrix_dimensions = [self.range_dimension, column_dim]
        output.set_shape(broadcast_batch_shape.concatenate(matrix_dimensions))
    return output
def _solve(self, rhs, adjoint=False, adjoint_arg=False):
    if adjoint_arg:
        rhs = linalg.adjoint(rhs)
    batch_shape = array_ops.concat([array_ops.ones_like(self.batch_shape_tensor()), [1, 1]], 0)
    rhs += array_ops.zeros(batch_shape, dtype=rhs.dtype.base_dtype)
    output = _rotate_last_dim(rhs, rotate_right=True)
    output = output[(array_ops.newaxis, ...)]
    for operator in self.operators[:(- 1)]:
        if adjoint:
            operator_dimension = operator.range_dimension_tensor()
        else:
            operator_dimension = operator.domain_dimension_tensor()
        output = _unvec_by(output, operator_dimension)
        output = array_ops.matrix_transpose(output)
        output = operator.solve(output, adjoint=adjoint, adjoint_arg=False)
        output = array_ops.matrix_transpose(output)
        output = _rotate_last_dim(output, rotate_right=False)
        output = _vec(output)
        output = _rotate_last_dim(output, rotate_right=True)
    output = self.operators[(- 1)].solvevec(output, adjoint=adjoint)
    output = _rotate_last_dim(output, rotate_right=False)
    output = _vec(output)
    output = _rotate_last_dim(output, rotate_right=False)
    if rhs.shape.is_fully_defined():
        column_dim = rhs.shape[(- 1)]
        broadcast_batch_shape = common_shapes.broadcast_shape(rhs.shape[:(- 2)], self.batch_shape)
        if adjoint:
            matrix_dimensions = [self.domain_dimension, column_dim]
        else:
            matrix_dimensions = [self.range_dimension, column_dim]
        output.set_shape(broadcast_batch_shape.concatenate(matrix_dimensions))
    return output