code: def wrap_and_call(fn, acts, labels, device):
      if not torch.is_tensor(acts):
          acts = torch.tensor(acts)
  
      if "cuda" in device:
          acts = acts.cuda()
  
      if not acts.requires_grad:
          acts.requires_grad = True
  
      lengths = [acts.shape[1]] * acts.shape[0]
      label_lengths = [len(l) for l in labels]
      labels = torch.LongTensor(labels)
      lengths = torch.LongTensor(lengths)
      label_lengths = torch.LongTensor(label_lengths)
      if "cuda" in device:
          labels = labels.cuda()
          lengths = lengths.cuda()
          label_lengths = label_lengths.cuda()
  
      costs = fn(acts, labels, lengths, label_lengths)
      cost = torch.sum(costs)
      cost.backward()
  
      if "cuda" in device:
          torch.cuda.synchronize()
  
      if acts.grad is not None:
          grad = acts.grad.data.cpu().numpy()
      else:
          grad = None
  
      return costs.data.cpu().numpy(), grad
  
imports: import random
  import numpy
  import pytest
  import torch
  from nemo.collections.asr.losses.rnnt import MultiblankRNNTLossPytorch, RNNTLossPytorch, TDTLossPytorch
  from nemo.collections.asr.parts.numba.rnnt_loss.rnnt_numpy import RNNTLoss
  from nemo.collections.asr.parts.numba.rnnt_loss.rnnt_pytorch import MultiblankRNNTLossNumba, RNNTLossNumba, TDTLossNumba
  from nemo.core.utils import numba_utils
  from nemo.core.utils.numba_utils import __NUMBA_MINIMUM_VERSION__
label_desc: Use image node_id 1 for calling a global function with example usage: wrap_and_call(fn, acts, labels, device) and returns: costs,  grad