code: def get_episode_dict(
      episode: Sequence[Any],
      episode_metadata: Dict[str, Any],
      episode_metadata_fn: Callable[
          [Dict[str, Any]], Optional[Dict[str, Any]]
      ] = lambda x: x,
      step_fn: Callable[[Dict[str, Any]], Dict[str, Any]] = lambda x: x,
  ) -> Optional[Dict[str, Any]]:
      """Obtains an RLDS episode from an Envlogger episode.
  
      Args:
        episode: sequence of envlogger.StepData.
        episode_metadata: metadata as obtained from the envlogger reader.
        episode_metadata_fn: function to process the episode metadata. If it returns
          None, the steps are not read and this function returns None.
        step_fn: function that processes each RLDS step once it's built from the raw
          data.
  
      Returns:
         Episode (or None if episode_metadata_fn returns None).
      """
      if episode_metadata:
          episode_dict = episode_metadata
      else:
          episode_dict = _get_episode_metadata(episode)
      episode_dict = episode_metadata_fn(episode_dict)
      if episode_dict is None:
          return None
      steps = _generate_steps(episode, step_fn)
  
      episode_dict["steps"] = steps
      return episode_dict
  
file_path: datasets/tensorflow_datasets/rlds/envlogger_reader.py
imports: from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Tuple, Union
  import numpy
  from tensorflow_datasets.core.utils import tree_utils
label_desc: Use image node_id 3 for calling a global function with example usage: get_episode_dict(episode, episode_metadata, episode_metadata_fn, step_fn) and returns: episode_dict, None