def _convert_gptq_scales_qzeros(scales, qzeros, inplace=True):
    """
    GPTQ format:
        scales: (n_groups, N)
        qzeros: (n_groups, N // 8)
        qzeros are substracted by 1 before packing

    Desired format:
        scales: (N, n_groups)
        qzeros: (N, n_groups)

    Note:
        N = output channels or output features
        n_groups = math.ceil(IC / group_size)
    """
    N = scales.shape[1]
    n_groups = scales.shape[0]
    scales = scales.t_().contiguous() if inplace else scales.t().contiguous()
    if qzeros is None:
        return scales, qzeros
    zp_dtype = torch.int32
    zp = torch.empty((n_groups, N), dtype=zp_dtype)
    # Steps to convert qzeros:
    # (1) unpack qzeros to (n_groups, N)
    # (2) take transpose
    # (3) plus one and handle overflow
    zp_bits = 4  # int4
    comp_dtype_bits = 32  # int32
    comp_ratio = comp_dtype_bits // zp_bits
    mask = 2**zp_bits - 1
    for i in range(comp_ratio):
        zp[:, i::comp_ratio] = (qzeros >> (zp_bits * i)) & mask

    zp = zp.t_().contiguous() if inplace else zp.t().contiguous()
    zp += 1
    # it may overflow after adding one
    zp = torch.where(zp > (2**zp_bits - 1), 0, zp)

    return scales, zp

    GPTQ format:
        scales: (n_groups, N)
        qzeros: (n_groups, N // 8)
        qzeros are substracted by 1 before packing

    Desired format:
        scales: (N, n_groups)
        qzeros: (N, n_groups)

    Note:
        N = output channels or output features
        n_groups = math.ceil(IC / group_size)
    
intel_extension_for_pytorch/nn/utils/_model_convert.py