code: def init_lm_state(lm_model: torch.nn.Module):
      """Initialize LM hidden states.
  
      Args:
          lm_model: LM module.
  
      Returns:
          lm_state: Initial LM hidden states.
  
      """
      lm_layers = len(lm_model.rnn)
      lm_units_typ = lm_model.typ
      lm_units = lm_model.n_units
  
      p = next(lm_model.parameters())
  
      h = [
          torch.zeros(lm_units).to(device=p.device, dtype=p.dtype)
          for _ in range(lm_layers)
      ]
  
      lm_state = {"h": h}
  
      if lm_units_typ == "lstm":
          lm_state["c"] = [
              torch.zeros(lm_units).to(device=p.device, dtype=p.dtype)
              for _ in range(lm_layers)
          ]
  
      return lm_state
  
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 8 for calling a global function with example usage: init_lm_state(lm_model) and returns: lm_state