code: def test_fancy_indexing():
      t = ones((100, 200, 300))
      t2 = t[[0, 1], [2, 3]]
      assert t2.shape == (2, 300)
  
      t3 = t[[[0, 1], [2, 3]], [4, 5]]
      assert t3.shape == (2, 2, 300)
  
      with pytest.raises(IndexError) as cm:
          _ = t[[1, 2], [3, 4, 5]]  # noqa: F841
      e = cm.value.args[0]
      assert (
          e == "shape mismatch: indexing arrays could not be broadcast "
          "together with shapes (2,) (3,)"
      )
  
      with pytest.raises(IndexError):
          t[[100]]
  
      t = ones((100, 200, 300), chunk_size=10)
  
      # fancy index on numpy ndarrays
  
      t4 = tile(t[:10, -10:, [13, 244, 151, 242, 34]])
      assert t4.shape == (10, 10, 5)
      assert t4.chunk_shape == (1, 1, 1)
  
      t5 = tile(t[:10, -10:, [1, 10, 20, 33, 34, 200]])
      assert t5.shape == (10, 10, 6)
      assert t5.chunk_shape == (1, 1, 5)
  
      t6 = tile(t[[20, 1, 33, 22, 11], :15, [255, 211, 2, 11, 121]])
      assert t6.shape == (5, 15)
      # need a concat, because the fancy indexes are not ascending according to chunk index
      assert t6.chunk_shape == (1, 2)
      assert t6.chunks[0].ndim == 2
      assert t6.nsplits == ((5,), (10, 5))
  
      t7 = tile(t[[5, 6, 33, 66], :15, [0, 9, 2, 11]])
      assert t7.shape == (4, 15)
      # not need a concat
      assert t7.chunk_shape == (3, 2)
      assert t7.chunks[0].ndim == 2
      assert t7.nsplits == ((2, 1, 1), (10, 5))
  
      t8 = tile(t[[[5, 33], [66, 6]], :15, [255, 11]])
      assert t8.shape == (2, 2, 15)
      assert t8.chunk_shape == (1, 1, 2)
      assert t8.chunks[0].ndim == 3
      assert t8.nsplits == ((2,), (2,), (10, 5))
  
      # fancy index on tensors
  
      t9 = tile(
          t[:10, -10:, tensor([13, 244, 151, 242, 34], chunk_size=2)]
      )
      assert t9.shape == (10, 10, 5)
      assert t9.chunk_shape == (1, 1, 3)
  
      t10 = tile(
          t[:10, -10:, tensor([1, 10, 20, 33, 34, 200], chunk_size=4)]
      )
      assert t10.shape == (10, 10, 6)
      assert t10.chunk_shape == (1, 1, 2)
  
      t11 = tile(
          t[
              tensor([20, 1, 33, 22, 11], chunk_size=2),
              :15,
              tensor([255, 211, 2, 11, 121], chunk_size=3),
          ]
      )
      assert t11.shape == (5, 15)
      # need a concat, because the fancy indexes are not ascending according to chunk index
      assert t11.chunk_shape == (4, 2)
      assert t11.chunks[0].ndim == 2
      assert t11.nsplits == ((2, 1, 1, 1), (10, 5))
  
      t12 = tile(
          t[tensor([5, 6, 33, 66], chunk_size=2), :15, [0, 9, 2, 11]]
      )
      assert t12.shape == (4, 15)
      # not need a concat
      assert t12.chunk_shape == (2, 2)
      assert t12.chunks[0].ndim == 2
      assert t12.nsplits == ((2, 2), (10, 5))
  
      t13 = tile(t[tensor([[5, 33], [66, 6]]), :15, tensor([255, 11])])
      assert t13.shape == (2, 2, 15)
      assert t13.chunk_shape == (1, 1, 2)
      assert t13.chunks[0].ndim == 3
      assert t13.nsplits == ((2,), (2,), (10, 5))
  
imports: import numpy
  import pytest
  from ....config import option_context
  from ....core import tile
  from ...base.broadcast_to import TensorBroadcastTo
  from ...datasource import ones, tensor, array, empty
  from ...datasource.ones import TensorOnes
  from ...merge.concatenate import TensorConcatenate
  from ..None import choose, unravel_index, nonzero, compress, fill_diagonal
  from ..setitem import TensorIndexSetValue
label_desc: Use image node_id 3 for calling a global function with example usage: test_fancy_indexing() without return types