class_docstr: Data loading worker used to map states to actual observations.
docstr: Load trajectory data from the provided trajectory file paths. Report exceptions to the main process.
  
  :param env_factory: Function for creating an environment for MazeState and MazeAction conversion.
  :param trajectories_or_paths: Either file paths to load, or already loaded trajectories to convert.
  :param reporting_queue: Queue for reporting loaded data and exceptions back to the main process.
  :param trajectory_processor: A trajectory processor class.
code: def run(
      env_factory: Callable,
      trajectories_or_paths: List[Union[Path, str, TrajectoryRecord]],
      reporting_queue: Queue,
      trajectory_processor: TrajectoryProcessor,
  ) -> None:
      """Load trajectory data from the provided trajectory file paths. Report exceptions to the main process.
  
      :param env_factory: Function for creating an environment for MazeState and MazeAction conversion.
      :param trajectories_or_paths: Either file paths to load, or already loaded trajectories to convert.
      :param reporting_queue: Queue for reporting loaded data and exceptions back to the main process.
      :param trajectory_processor: A trajectory processor class.
      """
      try:
          env = env_factory() if env_factory else None
          for trajectory_or_file in trajectories_or_paths:
              # If we got a file path, then deserialize, convert, and report all trajectories in it
              if isinstance(trajectory_or_file, Path) or isinstance(
                  trajectory_or_file, str
              ):
                  for (
                      trajectory
                  ) in InMemoryDataset.deserialize_trajectory(
                      trajectory_or_file
                  ):
                      for step_record in trajectory_processor.process(
                          trajectory, env
                      ):
                          reporting_queue.put(step_record)
              # If we got an already-loaded trajectory, then just convert and report it
              elif isinstance(trajectory_or_file, TrajectoryRecord):
                  for step_record in trajectory_processor.process(
                      trajectory_or_file, env
                  ):
                      reporting_queue.put(step_record)
              else:
                  raise RuntimeError(
                      f"Expected a path or a loaded trajectory record, got {type(trajectory_or_file)}"
                  )
  
          reporting_queue.put(DataLoadWorker.DONE_TOKEN)
  
      except Exception as exception:
          # Ship exception along with a traceback to the main process
          reporting_queue.put(ExceptionReport(exception))
          raise
  
imports: import itertools
  import logging
  import pickle
  from abc import ABC
  from itertools import chain
  from multiprocessing import Queue, Process
  from pathlib import Path
  from typing import Callable, List, Union, Optional, Tuple
  from typing import Dict, Sequence, Generator
  import torch
  from omegaconf import ListConfig
  from torch.utils.data import Dataset, Subset
  from tqdm import tqdm
  from maze.core.env.action_conversion import ActionType, TorchActionType
  from maze.core.env.observation_conversion import ObservationType, TorchObservationType
  from maze.core.env.structured_env import ActorID
  from maze.core.trajectory_recording.datasets.trajectory_processor import TrajectoryProcessor
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
  from maze.core.trajectory_recording.records.trajectory_record import TrajectoryRecord
  from maze.core.utils.factory import ConfigType, Factory
  from maze.utils.exception_report import ExceptionReport
label_desc: Use image node_id 1 for calling the DataLoadWorker obj's underlying member method code with example usage: obj.run(env_factory, trajectories_or_paths, reporting_queue, trajectory_processor) without return types