code: def recurrent_state_from_numpy(recurrent_state, device):
      """Convert a recurrent state in numpy.ndarray to torch.Tensor.
  
      Args:
          recurrent_state (object): Recurrent state in numpy.ndarray.
          device (torch.Device): Device the recurrent state is moved to.
  
      Returns:
          object: Recurrent state in torch.Tensor of a given device.
      """
      if recurrent_state is None:
          return None
      elif isinstance(recurrent_state, np.ndarray):
          return torch.from_numpy(recurrent_state).to(device)
      elif isinstance(recurrent_state, tuple):
          return tuple(
              recurrent_state_from_numpy(s, device)
              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 15 for calling a global function with example usage: recurrent_state_from_numpy(recurrent_state, device) and returns: None, torch, tuple