code: def _batch_index_helper(
      v: TensorStructType, i: int, j: int
  ) -> TensorStructType:
      """Selects the item at the ith batch index and jth repetition."""
      if isinstance(v, dict):
          return {
              k: _batch_index_helper(u, i, j) for (k, u) in v.items()
          }
      elif isinstance(v, tuple):
          return tuple(_batch_index_helper(u, i, j) for u in v)
      elif isinstance(v, list):
          # This is the output of unbatch_repeat_dim(). Unfortunately we have to
          # process it here instead of in unbatch_all(), since it may be buried
          # under a dict / tuple.
          return _batch_index_helper(v[j], i, j)
      elif isinstance(v, RepeatedValues):
          unbatched = v.unbatch_all()
          # Don't need to select j here; that's already done in unbatch_all.
          return unbatched[i]
      else:
          return v[i, ...]
  
file_path: ray/rllib/models/repeated_values.py
imports: from typing import List
  from ray.rllib.utils.annotations import PublicAPI
  from ray.rllib.utils.typing import TensorType, TensorStructType
label_desc: Use image node_id 3 for calling a global function with example usage: _batch_index_helper(v, i, j) and returns: unknown, tuple, _batch_index_helper, unbatched, v