code: def pack_hypotheses(
      hypotheses: List[rnnt_utils.Hypothesis],
      logitlen: torch.Tensor,
  ) -> List[rnnt_utils.Hypothesis]:
      if logitlen is not None:
          if hasattr(logitlen, "cpu"):
              logitlen_cpu = logitlen.to("cpu")
          else:
              logitlen_cpu = logitlen
  
      for idx, hyp in enumerate(
          hypotheses
      ):  # type: rnnt_utils.Hypothesis
          hyp.y_sequence = torch.tensor(
              hyp.y_sequence, dtype=torch.long
          )
  
          if logitlen is not None:
              hyp.length = logitlen_cpu[idx]
  
          if hyp.dec_state is not None:
              hyp.dec_state = _states_to_device(hyp.dec_state)
  
      return hypotheses
  
imports: from dataclasses import dataclass, field
  from typing import List, Optional
  import torch
  from omegaconf import DictConfig, OmegaConf
  from nemo.collections.asr.parts.utils import rnnt_utils
  from nemo.collections.asr.parts.utils.asr_confidence_utils import ConfidenceMethodConfig, ConfidenceMethodMixin
  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 1 for calling a global function with example usage: pack_hypotheses(hypotheses, logitlen) and returns: hypotheses