class_docstr: Base class of trajectory data set for imitation learning that keeps all loaded data in memory.
  
  Provides the main functionality for parsing and appending records.
  
  :param input_data: The optional input data to fill the dataset with. This can be either a single file, a single
          directory, a list of files or a list of directories.
  :param conversion_env_factory: Function for creating an environment for state and action
          conversion. For Maze envs, the environment configuration (i.e. space interfaces,
          wrappers etc.) determines the format of the actions and observations that will be derived
          from the recorded MazeActions and MazeStates (e.g. multi-step observations/actions etc.).
  :param n_workers: Number of worker processes to load data in.
  :param trajectory_processor: The processor object for processing and converting individual trajectories.
  :param deserialize_in_main_thread: Specify whether to deserialize the trajectories in the main thread (True) or in
          in the workers. In case only one trajectory file is given and this file holds many trajectories which all
          have to be converted with the conversion env setting this value to true makes sense as the expensive
          operation is the conversion. However if many files are given where no conversion is necessary the expensive
          operation is the deserialization, and thus should happen in the worker threads. Only relevant if
          n_workers > 1.
docstr: Size of the dataset.
  
  :return: Number of records (i.e. recorded flat-env steps) available
code: def __len__(self) -> int:
      """Size of the dataset.
  
      :return: Number of records (i.e. recorded flat-env steps) available
      """
      return len(self.step_records)
  
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 6 for calling the InMemoryDataset obj's underlying member method code with example usage: obj.__len__() and returns: len