code: def pack_hypotheses(
      hypotheses: List[rnnt_utils.NBestHypotheses],
      logitlen: torch.Tensor,
  ) -> List[rnnt_utils.NBestHypotheses]:
      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.NBestHypotheses
          for candidate_idx, cand in enumerate(hyp.n_best_hypotheses):
              cand.y_sequence = torch.tensor(
                  cand.y_sequence, dtype=torch.long
              )
  
              if logitlen is not None:
                  cand.length = logitlen_cpu[idx]
  
              if cand.dec_state is not None:
                  cand.dec_state = _states_to_device(cand.dec_state)
  
      return hypotheses
  
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 1 for calling a global function with example usage: pack_hypotheses(hypotheses, logitlen) and returns: hypotheses