docs: def _encode(segments, error, version, mask, eci, boost_error, sa_info=None):
      """\
      Creates a (Micro) QR Code.
  
      NOTE: This function does not check if the input is valid and does not belong
      to the public API.
      """
      is_micro = version < 1
      sa_mode = sa_info is not None
      buff = Buffer()
      ver = version
      ver_range = version
      if not is_micro:
          ver = None
          ver_range = version_range(version)
      if boost_error:
          error = boost_error_level(version, error, segments, eci, is_sa=sa_mode)
      if sa_mode:
          # ISO/IEC 18004:2015(E) -- 8 Structured Append (page 59)
          for i in sa_info[:3]:
              buff.append_bits(i, 4)
          buff.append_bits(sa_info.parity, 8)
      # ISO/IEC 18004:2015(E) -- 7.4 Data encoding (page 22)
      for segment in segments:
          write_segment(buff, segment, ver, ver_range, eci)
      capacity = consts.SYMBOL_CAPACITY[version][error]
      # ISO/IEC 18004:2015(E) -- 7.4.9 Terminator (page 32)
      write_terminator(buff, capacity, ver, len(buff))
      #  ISO/IEC 18004:2015(E) -- 7.4.10 Bit stream to codeword conversion (page 34)
      write_padding_bits(buff, version, len(buff))
      # ISO/IEC 18004:2015(E) -- 7.4.10 Bit stream to codeword conversion (page 34)
      write_pad_codewords(buff, version, capacity, len(buff))
      # ISO/IEC 18004:2015(E) -- 7.6 Constructing the final message codeword sequence (page 45)
      buff = make_final_message(version, error, buff.toints())
      # Matrix with timing pattern and reserved format / version regions
      matrix = make_matrix(version)
      # ISO/IEC 18004:2015 -- 6.3.3 Finder pattern (page 16)
      add_finder_patterns(matrix, is_micro)
      # ISO/IEC 18004:2015 -- 6.3.6 Alignment patterns (page 17)
      add_alignment_patterns(matrix, version)
      # ISO/IEC 18004:2015 -- 7.7 Codeword placement in matrix (page 46)
      add_codewords(matrix, buff, version)
      # ISO/IEC 18004:2015(E) -- 7.8.2 Data mask patterns (page 50)
      # ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results (page 53)
      mask = find_and_apply_best_mask(matrix, version, is_micro, mask)
      # ISO/IEC 18004:2015(E) -- 7.9 Format information (page 55)
      add_format_info(matrix, version, error, mask)
      # ISO/IEC 18004:2015(E) -- 7.10 Version information (page 58)
      add_version_info(matrix, version)
      return Code(matrix, version, error, mask, segments)