code: def create_lm_batch_states(
      lm_states: Union[List[Any], Dict[str, Any]],
      lm_layers,
      is_wordlm: bool,
  ) -> Union[List[Any], Dict[str, Any]]:
      """Create LM hidden states.
  
      Args:
          lm_states: LM hidden states.
          lm_layers: Number of LM layers.
          is_wordlm: Whether provided LM is a word-level LM.
  
      Returns:
          new_states: LM hidden states.
  
      """
      if is_wordlm:
          return lm_states
  
      new_states = {}
  
      new_states["c"] = [
          torch.stack([state["c"][layer] for state in lm_states])
          for layer in range(lm_layers)
      ]
      new_states["h"] = [
          torch.stack([state["h"][layer] for state in lm_states])
          for layer in range(lm_layers)
      ]
  
      return new_states
  
file_path: espnet/espnet/nets/pytorch_backend/transducer/utils.py
imports: import os
  from typing import Any, Dict, List, Optional, Union
  import numpy
  import torch
  from espnet.nets.pytorch_backend.nets_utils import pad_list
  from espnet.nets.transducer_decoder_interface import ExtendedHypothesis, Hypothesis
label_desc: Use image node_id 7 for calling a global function with example usage: create_lm_batch_states(lm_states, lm_layers, is_wordlm) and returns: new_states, lm_states