code: def test_create_hybrid_device_mesh_device_sorting(
      self,
      mesh_shape: tuple[int, ...],
      dcn_mesh_shape: tuple[int, ...],
  ):
      devices = mock_tpu_devices(4, 4, 4, "TPU v4", True, 2)
      reversed_slices_devices = list(
          np.flip(np.array(devices).reshape(2, -1), axis=0).flat
      )
      mesh = mesh_utils.create_hybrid_device_mesh(
          mesh_shape,
          dcn_mesh_shape,
          devices,
          should_sort_granules_by_key=False,
      )
      sorted_slices_mesh = mesh_utils.create_hybrid_device_mesh(
          mesh_shape,
          dcn_mesh_shape,
          reversed_slices_devices,
          should_sort_granules_by_key=True,
      )
      np.testing.assert_array_equal(mesh, sorted_slices_mesh)
      self.assertSetEqual(
          {0, 1},
          {d.slice_index for d in sorted_slices_mesh.flat},
      )
  
      reversed_slices_mesh = mesh_utils.create_hybrid_device_mesh(
          mesh_shape,
          dcn_mesh_shape,
          reversed_slices_devices,
          should_sort_granules_by_key=False,
      )
      self.assertSetEqual(
          {1, 0},
          {d.slice_index for d in reversed_slices_mesh.flat},
      )
  
imports: import collections
  from collections.abc import Sequence
  import dataclasses
  import numpy
  from absl import logging
  from absl.testing import absltest
  from absl.testing import parameterized
  from jax.experimental import mesh_utils
  from jax.sharding import Mesh
  from jax._src import test_util
label_desc: Use image node_id 5 for calling the MeshUtilsTest obj's underlying member method code with example usage: obj.test_create_hybrid_device_mesh_device_sorting(mesh_shape, dcn_mesh_shape) without return types