# Path: envlogger/step_data.py
# class StepData(NamedTuple):
# 
# Path: envlogger/converters/codec.py
# _SCALAR_DIM_SIZE = -438
# def _python_int_to_bytes(py_int: int) -> bytes:
# def _set_datum_values_from_scalar(scalar: Union[ScalarNumber, bool, str, bytes],
#                                   datum: storage_pb2.Datum) -> bool:
# def _set_datum_values_from_array(array: np.ndarray,
#                                  values: storage_pb2.Datum.Values) -> None:
# def encode(
#     user_data: Union[np.ndarray, List[Any], Tuple[Any, ...], Dict[str, Any]]
# ) -> storage_pb2.Data:
# def decode_datum(
#     datum: storage_pb2.Datum
# ) -> Union[np.ndarray, ScalarNumber, bool, str, bytes]:
#     def from_bigint(int_bytes):
# def decode(
#     user_data: storage_pb2.Data
# ) -> Optional[Union[ScalarNumber, bool, str, bytes, np.ndarray, List[Any],


import abc
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, TypeVar, Union
from absl import logging
from envlogger import step_data
from envlogger.backends.python import episode_info
from envlogger.converters import codec

    def get_nth_step_from_episode(j: int):
      return self._get_nth_step(episode.start + j)

    return _SequenceAdapter(
        count=episode.num_steps, get_nth_item=get_nth_step_from_episode)

  def _get_nth_episode_metadata(self, i: int) -> Optional[Any]:
    """Returns the metadata for episode `i` (0-based)."""
    episode = self._get_nth_episode_info(i, include_metadata=True)
    return codec.decode(episode.metadata)

  def __enter__(self):
    return self

  def __exit__(self, exc_type, exc_value, tb):
    self.close()

  def __del__(self):
    self.close()

  @abc.abstractmethod
  def close(self) -> None:
    pass

  @abc.abstractmethod
  def metadata(self) -> Dict[str, Any]:
    pass

  @property

# Path: envlogger/step_data.py
# class StepData(NamedTuple):
# 
# Path: envlogger/converters/codec.py
# _SCALAR_DIM_SIZE = -438
# def _python_int_to_bytes(py_int: int) -> bytes:
# def _set_datum_values_from_scalar(scalar: Union[ScalarNumber, bool, str, bytes],
#                                   datum: storage_pb2.Datum) -> bool:
# def _set_datum_values_from_array(array: np.ndarray,
#                                  values: storage_pb2.Datum.Values) -> None:
# def encode(
#     user_data: Union[np.ndarray, List[Any], Tuple[Any, ...], Dict[str, Any]]
# ) -> storage_pb2.Data:
# def decode_datum(
#     datum: storage_pb2.Datum
# ) -> Union[np.ndarray, ScalarNumber, bool, str, bytes]:
#     def from_bigint(int_bytes):
# def decode(
#     user_data: storage_pb2.Data
# ) -> Optional[Union[ScalarNumber, bool, str, bytes, np.ndarray, List[Any],


# Path: envlogger/backends/backend_reader.py
import abc
from typing import Any, Callable, Dict, Generic, Iterator, List, Optional, Sequence, TypeVar, Union
from absl import logging
from envlogger import step_data
from envlogger.backends.python import episode_info
from envlogger.converters import codec


    def get_nth_step_from_episode(j: int):
      return self._get_nth_step(episode.start + j)

    return _SequenceAdapter(
        count=episode.num_steps, get_nth_item=get_nth_step_from_episode)

  def _get_nth_episode_metadata(self, i: int) -> Optional[Any]:
    """Returns the metadata for episode `i` (0-based)."""
    episode = self._get_nth_episode_info(i, include_metadata=True)
    return codec.decode(episode.metadata)

  def __enter__(self):
    return self

  def __exit__(self, exc_type, exc_value, tb):
    self.close()

  def __del__(self):
    self.close()

  @abc.abstractmethod
  def close(self) -> None:
    pass

  @abc.abstractmethod
  def metadata(self) -> Dict[str, Any]:
    pass

  @property

  def episodes(self) -> Sequence[Sequence[step_data.StepData]]: