docs: def _insert(self, sock_info, docs, ordered=True, check_keys=True,
                  manipulate=False, write_concern=None, op_id=None,
                  bypass_doc_val=False):
          """Internal insert helper."""
          if isinstance(docs, collections.Mapping):
              return self._insert_one(
                  sock_info, docs, ordered,
                  check_keys, manipulate, write_concern, op_id, bypass_doc_val)
  
          ids = []
  
          if manipulate:
              def gen():
                  """Generator that applies SON manipulators to each document
                  and adds _id if necessary.
                  """
                  _db = self.__database
                  for doc in docs:
                      # Apply user-configured SON manipulators. This order of
                      # operations is required for backwards compatibility,
                      # see PYTHON-709.
                      doc = _db._apply_incoming_manipulators(doc, self)
                      if not (isinstance(doc, RawBSONDocument) or '_id' in doc):
                          doc['_id'] = ObjectId()
  
                      doc = _db._apply_incoming_copying_manipulators(doc, self)
                      ids.append(doc['_id'])
                      yield doc
          else:
              def gen():
                  """Generator that only tracks existing _ids."""
                  for doc in docs:
                      # Don't inflate RawBSONDocument by touching fields.
                      if not isinstance(doc, RawBSONDocument):
                          ids.append(doc.get('_id'))
                      yield doc
  
          concern = (write_concern or self.write_concern).document
          acknowledged = concern.get("w") != 0
  
          command = SON([('insert', self.name),
                         ('ordered', ordered)])
          if concern:
              command['writeConcern'] = concern
          if op_id is None:
              op_id = message._randint()
          if bypass_doc_val and sock_info.max_wire_version >= 4:
              command['bypassDocumentValidation'] = True
          bwc = message._BulkWriteContext(
              self.database.name, command, sock_info, op_id,
              self.database.client._event_listeners)
          if sock_info.max_wire_version > 1 and acknowledged:
              # Batched insert command.
              results = message._do_batched_write_command(
                  self.database.name + ".$cmd", message._INSERT, command,
                  gen(), check_keys, self.__write_response_codec_options, bwc)
              _check_write_command_response(results)
          else:
              # Legacy batched OP_INSERT.
              message._do_batched_insert(self.__full_name, gen(), check_keys,
                                         acknowledged, concern, not ordered,
                                         self.__write_response_codec_options, bwc)
          return ids