code: def test_create_target_and_shifted_label_sequences():
      target_and_label = torch.tensor(
          [
              [C.BOS_ID, 4, 17, 35, 12, C.EOS_ID, C.PAD_ID, C.PAD_ID],
              [C.BOS_ID, 15, 23, 23, 77, 55, 22, C.EOS_ID],
              [
                  C.BOS_ID,
                  4,
                  C.EOS_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
              ],
          ]
      )
      expected_label = torch.tensor(
          [
              [4, 17, 35, 12, C.EOS_ID, C.PAD_ID, C.PAD_ID],
              [15, 23, 23, 77, 55, 22, C.EOS_ID],
              [
                  4,
                  C.EOS_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
              ],
          ]
      ).unsqueeze(2)
      expected_target = torch.tensor(
          [
              [C.BOS_ID, 4, 17, 35, 12, C.PAD_ID, C.PAD_ID],
              [C.BOS_ID, 15, 23, 23, 77, 55, 22],
              [
                  C.BOS_ID,
                  4,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
                  C.PAD_ID,
              ],
          ]
      ).unsqueeze(2)
      target_and_label = torch.unsqueeze(target_and_label, dim=2)
      expected_lengths = torch.tensor([5, 7, 2])
  
      target, label = data_io.create_target_and_shifted_label_sequences(
          target_and_label
      )
  
      assert (
          target.shape[0] == label.shape[0] == target_and_label.shape[0]
      )
      assert (
          target.shape[1]
          == label.shape[1]
          == target_and_label.shape[1] - 1
      )
      assert torch.allclose(target, expected_target)
      assert torch.allclose(label, expected_label)
      lengths = (target != C.PAD_ID).sum(dim=1).squeeze()
      assert torch.allclose(lengths, expected_lengths)
  
imports: import os
  import random
  from tempfile import TemporaryDirectory
  from typing import Optional, List, Tuple
  import numpy
  import pytest
  import torch
  from sockeye import constants
  from sockeye import data_io
  from sockeye import utils
  from sockeye import vocab
  from sockeye.test_utils import tmp_digits_dataset
  from sockeye.utils import SockeyeError, get_tokens, seed_rngs
label_desc: Use image node_id 29 for calling a global function with example usage: test_create_target_and_shifted_label_sequences() without return types