code: def _states_to_device(dec_state, device="cpu"):
      if torch.is_tensor(dec_state):
          dec_state = dec_state.to(device)
  
      elif isinstance(dec_state, (list, tuple)):
          dec_state = tuple(
              _states_to_device(dec_i, device) for dec_i in dec_state
          )
  
      return dec_state
  
imports: import copy
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from tqdm import tqdm
  from nemo.collections.asr.modules import rnnt_abstract
  from nemo.collections.asr.parts.utils.rnnt_utils import HATJointOutput, Hypothesis, NBestHypotheses, is_prefix, select_k_expansions
  from nemo.core.classes import Typing, typecheck
  from nemo.core.neural_types import AcousticEncodedRepresentation, HypothesisType, LengthsType, NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 2 for calling a global function with example usage: _states_to_device(dec_state, device) and returns: dec_state