code: def autoscale(bp, optimal=6):
      
      slen = str(bp)
      tlen = slen[0:2] if len(slen) > 1 else slen[0]
      precision = len(slen) - 2  # how many zeros we need to pad?
      bp_len_scaled = int(tlen)  # scale bp_len to range (0, 100)
      tick_diffs = [(x, abs(bp_len_scaled / x - optimal)) for x in [1, 2, 5, 10]]
      best_stride, best_tick_diff = min(tick_diffs, key=lambda x: x[1])
  
      while precision > 0:
          best_stride *= 10
          precision -= 1
  
      return best_stride
docs: >>> autoscale(150000000)
      20000000
      >>> autoscale(97352632)
      10000000