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 math
  import os
  from dataclasses import dataclass, field
  from typing import List, Optional, Tuple, Union
  import torch
  from nemo.collections.asr.parts.utils import rnnt_utils
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.core.classes import Typing, typecheck
  from nemo.core.neural_types import HypothesisType, LengthsType, LogprobsType, 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