def pi()

in automl21/scs_neural/solver/cone_projection.py [0:0]


    def pi(x, cones, dual=False):
        projection = torch.zeros_like(x)
        offset = 0
        for cone, sz in cones:
            sz = sz if isinstance(sz, (tuple, list)) else (sz,)
            if sum(sz) == 0:
                continue
            for dim in sz:
                if cone == 's':
                    upd_dim = int(dim * (dim + 1) / 2)
                    dim = upd_dim
                elif cone in ['e', 'ep', 'ed']:
                    raise NotImplementedError("Exp cone projection not implemented")
                projection[:, offset:offset + dim] = ConeProjection._proj(
                    x[:, offset:offset + dim], cone, dual=dual)
                offset += dim
        return projection