code: def transform_loop(dataloader, transform_fn, out_queue, done_event):
      # This setting is thread local, and prevents the copy in pin_memory from
      # consuming all CPU cores.
      torch.set_num_threads(1)
  
      for data in dataloader:
          if done_event.is_set():
              break
          transformed_data = transform_fn(data)
  
          while not done_event.is_set():
              try:
                  out_queue.put(
                      transformed_data, timeout=MP_STATUS_CHECK_INTERVAL
                  )
                  break
              except queue.Full:
                  continue
          # save memory
          del transformed_data
  
      if not done_event.is_set():
          done_event.set()
  
imports: import queue
  import threading
  from typing import Dict, List, Union
  import torch
  from torch.utils.data._utils import MP_STATUS_CHECK_INTERVAL
  from torchrec import EmbeddingBagConfig, EmbeddingConfig
  from torchrec.distributed.model_parallel import DistributedModelParallel
  from torchrec.sparse.jagged_tensor import KeyedJaggedTensor
  from .id_transformer_group import IDTransformerGroup
label_desc: Use image node_id 1 for calling a global function with example usage: transform_loop(dataloader, transform_fn, out_queue, done_event) without return types