code: def rle_encode(img:NPArrayMask)->str:
      "Return run-length encoding string from `img`."
      pixels = np.concatenate([[0], img.flatten() , [0]])
      runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
      runs[1::2] -= runs[::2]
      return ' '.join(str(x) for x in runsf rle_encode(img:NPArrayMask)->str:
      "Return run-length encoding string from `img`."
      pixels = np.concatenate([[0], img.flatten() , [0]])
      runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
      runs[1::2] -= runs[::2]
      return ' '.join(str(x) for x in runs)
docs: Return run-length encoding string from `img`.