code: def _create_tensor_dicts(input_queue: Queue,
                           output_queue: Queue,
                           iterator: DataIterator,
                           shuffle: bool,
                           index: int) -> None:
      
      def instances() -> Iterator[Instance]:
          instance = input_queue.get()
          while instance is not None:
              yield instance
              instance = input_queue.get()
  
      for tensor_dict in iterator(instances(), num_epochs=1, shuffle=shuffle):
          output_queue.put(tensor_dict)
  
      output_queue.put(index)
docs: Pulls at most ``max_instances_in_memory`` from the input_queue,
      groups them into batches of size ``batch_size``, converts them
      to ``TensorDict`` s, and puts them on the ``output_queue``.