def METHOD_NAME(cls,
             func_name: str = None,
             warmup: int = 1,
             log_interval: int = 1,
             with_sync: bool = False,
             file: Optional[str] = None,
             logger: Optional[Logger] = None,
             batch_size: int = 1,
             **kwargs):
    """Activate the time counter.
    Args:
        func_name (str): Specify which function to activate. If not
            specified, all registered function will be activated.
        warmup (int): the warm up steps, default 1.
        log_interval (int): Interval between each log, default 1.
        with_sync (bool): Whether use cuda synchronize for time counting,
            default False.
        file (str | None): The file to save output messages. The default
            is `None`.
        logger (Logger): The logger for the timer. Default to None.
        batch_size (int): The batch size. Default to 1.
    """
    assert warmup >= 1
    if logger is None:
        logger = get_logger('test', log_file=file)
    cls.logger = logger
    if func_name is not None:
        warnings.warn('func_name must be globally unique if you call '
                      'activate multiple times')
        assert func_name in cls.names, '{} must be registered before '\
            'setting params'.format(func_name)
        cls.names[func_name]['warmup'] = warmup
        cls.names[func_name]['log_interval'] = log_interval
        cls.names[func_name]['with_sync'] = with_sync
        cls.names[func_name]['batch_size'] = batch_size
        cls.names[func_name]['enable'] = True
    else:
        for name in cls.names:
            cls.names[name]['warmup'] = warmup
            cls.names[name]['log_interval'] = log_interval
            cls.names[name]['with_sync'] = with_sync
            cls.names[name]['batch_size'] = batch_size
            cls.names[name]['enable'] = True
    yield
    if func_name is not None:
        cls.names[func_name]['enable'] = False
    else:
        for name in cls.names:
            cls.names[name]['enable'] = False