human
What is a the Python code you requested given the following:
Complete the below
def _to_byte_string(value, num_bits):

    ''''Convert an integer to a big-endian string of bytes with padding.
    Padding is added at the end (i.e. after the least-significant bit) if
    required.'
    '''
assistant
#Here is the Python code you requested.
    shifts = six.moves.xrange((num_bits - 8), (-8), (-8))
    def byte_at(off):
        return (((value >> off) if (off >= 0) else (value << (- off))) & 255)
    return ''.join((six.int2byte(byte_at(offset)) for offset in shifts))