code: def _extract_labels(sp_model, samples: List):
      targets = [
          sp_model.encode(sample[-1].lower()) for sample in samples
      ]
      lengths = torch.tensor([len(elem) for elem in targets]).to(
          dtype=torch.int32
      )
      targets = torch.nn.utils.rnn.pad_sequence(
          [torch.tensor(elem) for elem in targets],
          batch_first=True,
          padding_value=1.0,
      ).to(dtype=torch.int32)
      return targets, lengths
  
imports: import random
  from typing import List
  import sentencepiece
  import torch
  import torchvision
  from data_module import LRS3DataModule
  from lightning import Batch
  from lightning_av import AVBatch
label_desc: Use image node_id 1 for calling a global function with example usage: _extract_labels(sp_model, samples) and returns: targets,  lengths