code: def _apply_mt(self, doc_loader, parallelism, **kwargs):
          
          if not Meta.postgres:
              raise ValueError("Fonduer must use PostgreSQL as a database backend.")
  
          def fill_input_queue(in_queue, doc_loader, terminal_signal):
              for doc in doc_loader:
                  in_queue.put(doc)
              in_queue.put(terminal_signal)
  
          # Create an input queue to feed documents to UDF workers
          manager = Manager()
          in_queue = manager.Queue()
          # Use an output queue to track multiprocess progress
          out_queue = JoinableQueue()
  
          total_count = len(doc_loader)
  
          # Start UDF Processes
          for i in range(parallelism):
              udf = self.udf_class(
                  in_queue=in_queue,
                  out_queue=out_queue,
                  worker_id=i,
                  **self.udf_init_kwargs,
              )
              udf.apply_kwargs = kwargs
              self.udfs.append(udf)
  
          # Start the UDF processes, and then join on their completion
          for udf in self.udfs:
              udf.start()
  
          # Fill input queue with documents
          terminal_signal = UDF.QUEUE_CLOSED
          in_queue_filler = Process(
              target=fill_input_queue, args=(in_queue, doc_loader, terminal_signal)
          )
          in_queue_filler.start()
  
          count_parsed = 0
          while count_parsed < total_count:
              y = out_queue.get()
              # Update progress bar whenever an item has been processed
              if y == UDF.TASK_DONE:
                  count_parsed += 1
                  if self.pb is not None:
                      self.pb.update(1)
              else:
                  raise ValueError("Got non-sentinal output.")
  
          in_queue_filler.join()
          in_queue.put(UDF.QUEUE_CLOSED)
  
          for udf in self.udfs:
              udf.join()
  
          # Terminate and flush the processes
          for udf in self.udfs:
              udf.terminate()
          self.udfs = []
docs: Run the UDF multi-threaded using python multiprocessing