code: def test_split_unpack():
      """Test split_non_tensors and unpack_non_tensors."""
      x = torch.Tensor([1])
      y = torch.Tensor([2])
  
      # degenerate case, args is a single tensor.
      tensors, packed_non_tensors = split_non_tensors(x)
      assert tensors == (x,)
      assert packed_non_tensors is None
  
      tensors, packed_non_tensors = split_non_tensors((x, y, None, 3))
      assert tensors == (x, y)
      assert packed_non_tensors == {
          "is_tensor": [True, True, False, False],
          "objects": [None, 3],
      }
      recon = unpack_non_tensors(tensors, packed_non_tensors)
      assert recon == (x, y, None, 3)
  
      tensors, packed_non_tensors = split_non_tensors((None, 3, x, y))
      recon = unpack_non_tensors(tensors, packed_non_tensors)
      assert recon == (None, 3, x, y)
  
      tensors, packed_non_tensors = split_non_tensors((None, 3))
      recon = unpack_non_tensors(tensors, packed_non_tensors)
      assert recon == (None, 3)
  
      tensors, packed_non_tensors = split_non_tensors((x, y))
      recon = unpack_non_tensors(tensors, packed_non_tensors)
      assert recon == (x, y)
  
      recon = unpack_non_tensors(tensors, None)
      assert recon == (x, y)
  
      with pytest.raises(AssertionError):
          # assert the second arg should be a dict.
          recon = unpack_non_tensors(tensors, set())
  
      with pytest.raises(AssertionError):
          # assert the content of the second arg should be sane.
          recon = unpack_non_tensors(
              tensors, {"is_tensor": [], "objects": []}
          )
  
file_path: fairscale/tests/utils/test_containers.py
imports: from collections import OrderedDict, namedtuple
  import random
  import pytest
  import torch
  import torch.nn
  from fairscale.internal.containers import apply_to_tensors, pack_kwargs, split_non_tensors, unpack_kwargs, unpack_non_tensors
label_desc: Use image node_id 3 for calling a global function with example usage: test_split_unpack() without return types