code: def _insert_one(
              self, doc, ordered,
              check_keys, manipulate, write_concern, op_id, bypass_doc_val,
              session):
          
          if manipulate:
              doc = self.__database._apply_incoming_manipulators(doc, self)
              if not isinstance(doc, RawBSONDocument) and '_id' not in doc:
                  doc['_id'] = ObjectId()
              doc = self.__database._apply_incoming_copying_manipulators(doc,
                                                                         self)
          write_concern = write_concern or self.write_concern
          acknowledged = write_concern.acknowledged
          command = SON([('insert', self.name),
                         ('ordered', ordered),
                         ('documents', [doc])])
          if not write_concern.is_server_default:
              command['writeConcern'] = write_concern.document
  
          def _insert_command(session, sock_info, retryable_write):
              if not sock_info.op_msg_enabled and not acknowledged:
                  # Legacy OP_INSERT.
                  return self._legacy_write(
                      sock_info, 'insert', command, op_id,
                      bypass_doc_val, message.insert, self.__full_name,
                      [doc], check_keys, False, write_concern.document, False,
                      self.__write_response_codec_options)
  
              if bypass_doc_val and sock_info.max_wire_version >= 4:
                  command['bypassDocumentValidation'] = True
  
              result = sock_info.command(
                  self.__database.name,
                  command,
                  write_concern=write_concern,
                  codec_options=self.__write_response_codec_options,
                  check_keys=check_keys,
                  session=session,
                  client=self.__database.client,
                  retryable_write=retryable_write)
  
              _check_write_command_response(result)
  
          self.__database.client._retryable_write(
              acknowledged, _insert_command, session)
  
          if not isinstance(doc, RawBSONDocument):
              return doc.get('_id')
docs: Internal helper for inserting a single document.