code: def get_recurrent_state_at(recurrent_state, indices, detach):
      """Get a recurrent state at given indices.
  
      This function can be used to save a recurrent state so that you can
      reuse it when you replay past sequences.
  
      Args:
          indices (int or array-like of ints): Which recurrent state to get.
  
      Returns:
          object: Recurrent state of given indices.
      """
      if recurrent_state is None:
          return None
      elif isinstance(recurrent_state, torch.Tensor):
          if detach:
              recurrent_state = recurrent_state.detach()
          return recurrent_state[:, indices]
      elif isinstance(recurrent_state, tuple):
          return tuple(
              get_recurrent_state_at(s, indices, detach)
              for s in recurrent_state
          )
      else:
          raise ValueError(
              "Invalid recurrent state: {}".format(recurrent_state)
          )
  
file_path: pfrl/pfrl/utils/recurrent.py
imports: import itertools
  import numpy
  import torch
  from torch import nn
label_desc: Use image node_id 3 for calling a global function with example usage: get_recurrent_state_at(recurrent_state, indices, detach) and returns: None, recurrent_state, tuple