def seek(self, offset, whence=None, partition=None):
if whence is None:  <EOL><INDENT>if partition is None:<EOL><INDENT>for tmp_partition in self.offsets:<EOL><INDENT>self.offsets[tmp_partition] = offset<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.offsets[partition] = offset<EOL><DEDENT><DEDENT>elif whence == <NUM_LIT:1>:  <EOL><INDENT>if partition is None:<EOL><INDENT>for tmp_partition, _offset in self.offsets.items():<EOL><INDENT>self.offsets[tmp_partition] = _offset + offset<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.offsets[partition] += offset<EOL><DEDENT><DEDENT>elif whence in (<NUM_LIT:0>, <NUM_LIT:2>):  <EOL><INDENT>reqs = []<EOL>deltas = {}<EOL>if partition is None:<EOL><INDENT>(delta, rem) = divmod(offset, len(self.offsets))<EOL>for tmp_partition, r in izip_longest(self.offsets.keys(),<EOL>repeat(<NUM_LIT:1>, rem),<EOL>fillvalue=<NUM_LIT:0>):<EOL><INDENT>deltas[tmp_partition] = delta + r<EOL><DEDENT>for tmp_partition in self.offsets.keys():<EOL><INDENT>if whence == <NUM_LIT:0>:<EOL><INDENT>reqs.append(OffsetRequest(self.topic,<EOL>tmp_partition,<EOL>-<NUM_LIT:2>,<EOL><NUM_LIT:1>))<EOL><DEDENT>elif whence == <NUM_LIT:2>:<EOL><INDENT>reqs.append(OffsetRequest(self.topic,<EOL>tmp_partition,<EOL>-<NUM_LIT:1>,<EOL><NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>deltas[partition] = offset<EOL>if whence == <NUM_LIT:0>:<EOL><INDENT>reqs.append(OffsetRequest(self.topic, partition, -<NUM_LIT:2>, <NUM_LIT:1>))<EOL><DEDENT>elif whence == <NUM_LIT:2>:<EOL><INDENT>reqs.append(OffsetRequest(self.topic, partition, -<NUM_LIT:1>, <NUM_LIT:1>))<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>resps = self.client.send_offset_request(reqs)<EOL>for resp in resps:<EOL><INDENT>self.offsets[resp.partition] =resp.offsets[<NUM_LIT:0>] + deltas[resp.partition]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % whence)<EOL><DEDENT>self.fetch_offsets = self.offsets.copy()<EOL>self.count_since_commit += <NUM_LIT:1><EOL>if self.auto_commit:<EOL><INDENT>self.commit()<EOL><DEDENT>self.queue = queue.Queue()<EOL>
Alter the current offset in the consumer, similar to fseek

Arguments:
    offset: how much to modify the offset
    whence: where to modify it from, default is None

        * None is an absolute offset
        * 0    is relative to the earliest available offset (head)
        * 1    is relative to the current offset
        * 2    is relative to the latest known offset (tail)

    partition: modify which partition, default is None.
        If partition is None, would modify all partitions.