code: def rotate(path, max_num_log_files=1000):
      """Rotate a log-file while retaining past `max_num_log_files` files.
      Examples:
          /some/path/
          ├──logfile.txt
          ├──logfile.1.txt
          ├──logfile.2.txt
          >>> rotate('/some/path/logfile.txt')
          /some/path/
          ├──logfile.1.txt
          ├──logfile.2.txt
          ├──logfile.3.txt
      """
      for i in range(max_num_log_files - 1, -1, -1):
          if i == 0:
              p = Path(path)
              pn = p.parent / (p.stem + ".1" + p.suffix)
          else:
              _p = Path(path)
              p = _p.parent / (_p.stem + f".{i}" + _p.suffix)
              pn = _p.parent / (_p.stem + f".{i + 1}" + _p.suffix)
  
          if p.exists():
              if i == max_num_log_files - 1:
                  p.unlink()
              else:
                  shutil.move(p, pn)
  
imports: import argparse
  import shutil
  from pathlib import Path
label_desc: Use image node_id 1 for calling a global function with example usage: rotate(path, max_num_log_files) without return types