code: def execute(self, write_concern):
          
          if not self.ops:
              raise InvalidOperation('No operations to execute')
          if self.executed:
              raise InvalidOperation('Bulk operations can '
                                     'only be executed once.')
          self.executed = True
          write_concern = (WriteConcern(**write_concern) if
                           write_concern else self.collection.write_concern)
  
          if self.ordered:
              generator = self.gen_ordered()
          else:
              generator = self.gen_unordered()
  
          client = self.collection.database.client
          with client._socket_for_writes() as sock_info:
              if sock_info.max_wire_version < 5 and self.uses_collation:
                  raise ConfigurationError(
                      'Must be connected to MongoDB 3.4+ to use a collation.')
              if not write_concern.acknowledged:
                  if self.uses_collation:
                      raise ConfigurationError(
                          'Collation is unsupported for unacknowledged writes.')
                  self.execute_no_results(sock_info, generator)
              elif sock_info.max_wire_version > 1:
                  return self.execute_command(sock_info, generator, write_concern)
              else:
                  return self.execute_legacy(sock_info, generator, write_concern)
docs: Execute operations.