code: def resolve_rnnt_loss(
      loss_name: str, blank_idx: int, loss_kwargs: dict = None
  ) -> torch.nn.Module:
      loss_function_names = list(RNNT_LOSS_RESOLVER.keys())
  
      if loss_name not in loss_function_names:
          raise ValueError(
              f"Provided `loss_name` {loss_name} not in list of available RNNT losses \n"
              f"{loss_function_names}"
          )
  
      all_available_losses = {
          name: config
          for name, config in RNNT_LOSS_RESOLVER.items()
          if config.is_available
      }
  
      loss_config = RNNT_LOSS_RESOLVER[
          loss_name
      ]  # type: RNNTLossConfig
  
      # Re-raise import error with installation message
      if not loss_config.is_available:
          msg = (
              f"Installed RNNT losses are : {list(all_available_losses.keys())}.\n"
              f"****************************************************************\n"
              f"To install the selected loss function, please follow the steps below:\n"
              f"{loss_config.installation_msg}"
          )
          raise ImportError(msg)
  
      # Library version check
      if loss_config.min_version is not None:
          ver_matched, msg = model_utils.check_lib_version(
              loss_config.lib_name,
              checked_version=loss_config.min_version,
              operator=operator.ge,
          )
  
          if ver_matched is False:
              msg = (
                  f"{msg}\n"
                  f"****************************************************************\n"
                  f"To update the selected loss function, please follow the steps below:\n"
                  f"{loss_config.installation_msg}"
              )
              raise RuntimeError(msg)
  
      # Resolve loss functions sequentially
      loss_kwargs = {} if loss_kwargs is None else loss_kwargs
  
      if isinstance(loss_kwargs, DictConfig):
          loss_kwargs = OmegaConf.to_container(
              loss_kwargs, resolve=True
          )
  
      # Get actual loss name for `default`
      if loss_name == "default":
          loss_name = loss_config.loss_name
  
      """
      Resolve RNNT loss functions
      """
      if loss_name == "warprnnt":
          loss_func = warprnnt.RNNTLoss(
              blank=blank_idx, reduction="none"
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "warprnnt_numba":
          # Update loss config's forced float32 flag if set to None
          loss_config.force_float32 = (
              not numba_utils.is_numba_cuda_fp16_supported()
          )
  
          fastemit_lambda = loss_kwargs.pop("fastemit_lambda", 0.0)
          clamp = loss_kwargs.pop("clamp", -1.0)
          loss_func = RNNTLossNumba(
              blank=blank_idx,
              reduction="none",
              fastemit_lambda=fastemit_lambda,
              clamp=clamp,
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "pytorch":
          loss_func = RNNTLossPytorch(blank=blank_idx, reduction="none")
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "multiblank_rnnt":
          fastemit_lambda = loss_kwargs.pop("fastemit_lambda", 0.0)
          clamp = loss_kwargs.pop("clamp", -1.0)
          big_blank_durations = loss_kwargs.pop(
              "big_blank_durations", None
          )
          sigma = loss_kwargs.pop("sigma", 0.0)
          loss_func = MultiblankRNNTLossNumba(
              blank=blank_idx,
              big_blank_durations=big_blank_durations,
              reduction="none",
              fastemit_lambda=fastemit_lambda,
              clamp=clamp,
              sigma=sigma,
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "multiblank_rnnt_pytorch":
          big_blank_durations = loss_kwargs.pop(
              "big_blank_durations", None
          )
          sigma = loss_kwargs.pop("sigma", 0.0)
          loss_func = MultiblankRNNTLossPytorch(
              blank=blank_idx,
              big_blank_durations=big_blank_durations,
              reduction="none",
              sigma=sigma,
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "tdt":
          fastemit_lambda = loss_kwargs.pop("fastemit_lambda", 0.0)
          clamp = loss_kwargs.pop("clamp", -1.0)
          durations = loss_kwargs.pop("durations", None)
          sigma = loss_kwargs.pop("sigma", 0.0)
          omega = loss_kwargs.pop("omega", 0.0)
          loss_func = TDTLossNumba(
              blank=blank_idx,
              durations=durations,
              reduction="none",
              fastemit_lambda=fastemit_lambda,
              clamp=clamp,
              sigma=sigma,
              omega=omega,
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "tdt_pytorch":
          durations = loss_kwargs.pop("durations", None)
          sigma = loss_kwargs.pop("sigma", 0.0)
          loss_func = TDTLossPytorch(
              blank=blank_idx,
              durations=durations,
              reduction="none",
              sigma=sigma,
          )
          _warn_unused_additional_kwargs(loss_name, loss_kwargs)
  
      elif loss_name == "graph_rnnt":
          loss_kwargs = _clean_kwargs(
              loss_name,
              loss_kwargs,
              GraphRnntLoss.__init__,
              ignore_params={"blank"},
          )
          loss_func = GraphRnntLoss(blank=blank_idx, **loss_kwargs)
      elif loss_name == "graph_w_transducer":
          loss_kwargs = _clean_kwargs(
              loss_name,
              loss_kwargs,
              GraphWTransducerLoss.__init__,
              ignore_params={"blank"},
          )
          loss_func = GraphWTransducerLoss(
              blank=blank_idx, **loss_kwargs
          )
      else:
          raise ValueError(
              f"Invalid value of `loss_name`: {loss_name}. Allowed loss names are :"
              f"{loss_function_names}"
          )
  
      return loss_func
  
imports: import inspect
  import operator
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, List, Optional, Set
  import torch
  from omegaconf import DictConfig, OmegaConf
  from nemo.collections.asr.losses.rnnt_pytorch import MultiblankRNNTLossPytorch, RNNTLossPytorch, TDTLossPytorch
  from nemo.core.classes import Loss, typecheck
  from nemo.core.neural_types import LabelsType, LengthsType, LogprobsType, LossType, NeuralType
  from nemo.core.utils import numba_utils
  from nemo.core.utils.k2_utils import K2_INSTALLATION_MESSAGE
  from nemo.core.utils.numba_utils import NUMBA_INSTALLATION_MESSAGE
  from nemo.utils import logging, logging_mode, model_utils
label_desc: Use image node_id 4 for calling a global function with example usage: resolve_rnnt_loss(loss_name, blank_idx, loss_kwargs) and returns: loss_func