code: def execute(self, write_concern, session):
          
          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 = write_concern or self.collection.write_concern
          session = _validate_session_write_concern(session, write_concern)
  
          if self.ordered:
              generator = self.gen_ordered()
          else:
              generator = self.gen_unordered()
  
          client = self.collection.database.client
          if not write_concern.acknowledged:
              with client._socket_for_writes(session) as sock_info:
                  self.execute_no_results(sock_info, generator)
          else:
              return self.execute_command(generator, write_concern, session)
docs: Execute operations.