def counter(self, position=None, **kwargs):
for key, val in self.defaults.items():<EOL><INDENT>if key not in kwargs:<EOL><INDENT>kwargs[key] = val<EOL><DEDENT><DEDENT>kwargs['<STR_LIT>'] = self<EOL>counter = self.counter_class(**kwargs)<EOL>if position is None:<EOL><INDENT>toRefresh = []<EOL>if self.counters:<EOL><INDENT>pos = <NUM_LIT:2><EOL>for cter in reversed(self.counters):<EOL><INDENT>if self.counters[cter] < pos:<EOL><INDENT>toRefresh.append(cter)<EOL>cter.clear(flush=False)<EOL>self.counters[cter] = pos<EOL>pos += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>self.counters[counter] = <NUM_LIT:1><EOL>self._set_scroll_area()<EOL>for cter in reversed(toRefresh):<EOL><INDENT>cter.refresh(flush=False)<EOL><DEDENT>self.stream.flush()<EOL><DEDENT>elif position in self.counters.values():<EOL><INDENT>raise ValueError('<STR_LIT>' % position)<EOL><DEDENT>elif position > self.height:<EOL><INDENT>raise ValueError('<STR_LIT>' % position)<EOL><DEDENT>else:<EOL><INDENT>self.counters[counter] = position<EOL><DEDENT>return counter<EOL>
Args:
    position(int): Line number counting from the bottom of the screen
    kwargs(dict): Any additional :py:term:`keyword arguments<keyword argument>`
        are passed to :py:class:`Counter`

Returns:
    :py:class:`Counter`: Instance of counter class

Get a new progress bar instance

If ``position`` is specified, the counter's position can change dynamically if
additional counters are called without a ``position`` argument.