<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _validate_precinct_size(self, cparams):
 """ Precinct dimensions must satisfy certain restrictions if specified. They must both be a power of 2 and must both be at least twice the size of their codeblock size counterparts. """

        code_block_specified = False
        if cparams.cblockw_init != 0 and cparams.cblockh_init != 0:
            code_block_specified = True

        if cparams.res_spec != 0:
            # precinct size was not specified if this field is zero.
            for j in range(cparams.res_spec):
                prch = cparams.prch_init[j]
                prcw = cparams.prcw_init[j]
                if j == 0 and code_block_specified:
                    height, width = cparams.cblockh_init, cparams.cblockw_init
                    if prch < height * 2 or prcw < width * 2:
                        msg = ("The highest resolution precinct size "
                               "({prch} x {prcw}) must be at least twice that "
                               "of the code block size "
                               "({cbh} x {cbw}).")
                        msg = msg.format(prch=prch, prcw=prcw,
                                         cbh=height, cbw=width)
                        raise IOError(msg)
                if ((math.log(prch, 2) != math.floor(math.log(prch, 2)) or
                     math.log(prcw, 2) != math.floor(math.log(prcw, 2)))):
                    msg = ("Bad precinct size ({height} x {width}).  "
                           "Precinct dimensions must be powers of 2.")
                    msg = msg.format(height=prch, width=prcw)
                    raise IOError(msg)