code: def unshuffle_from_sc_to_cpu(
      t: tensor.Tensor,
      num_sparse_cores: int,
      offset_in_shard: int,
      size_in_shard: int,
      shard_rotation: int = 0,
  ) -> tensor.Tensor:
      """Unshuffles the sparse core sharded embedding tables to unsharded.
  
      This converts an input tensor respresenting stacked and sharded embedding
      table into a specific embedding table variable by using the provided
      metadata about the said table within the stacked, sharded embedding table.
      Args:
        t: The input stacked and sharded embedding table from sparsecore.
        num_sparse_cores: The number of sparsecores, this determines the number of
          shards that are present in the input t.
        offset_in_shard: Offset within a shard where the queried table starts.
        size_in_shard: size (number of rows) of this queried table within each shard
          of the input t.
        shard_rotation: The rotation of this table's shards.
  
      Returns:
        An embedding table which is part of the stacked embedding table t.
      """
      old_shape = t.shape
      # The width of the table must be a multiple of number of SC devices. The
      # tpu strategy does this round off at training time so we expect the
      # checkpoints value to meet this requirement.
      if t.shape[0] % num_sparse_cores != 0:
          raise ValueError(
              "The dim of table ({}) should be multiple of number of sparse cores"
              " ({})".format(t.shape[1], num_sparse_cores)
          )
      # get shards in the input t
      shards_t = array_ops.reshape(
          t,
          (
              num_sparse_cores,
              t.shape[0] // num_sparse_cores,
              t.shape[1],
          ),
      )
      # From each shard in t, get the part for just the queried table.
      shards = shards_t[
          :, offset_in_shard : offset_in_shard + size_in_shard, :
      ]
      # This table's shards were rotated by `shard_rotation`, so we need to rotate
      # the same amount in opposite direction
      if shard_rotation:
          shards = manip_ops.roll(shards, -shard_rotation, axis=0)
      # Re-arrange (transpose and reshape) the shards to get the queried embedding
      # table.
      intermediate_tensor = array_ops.transpose(shards, (1, 0, 2))
      new_shape = size_in_shard * num_sparse_cores, old_shape[1]
      return array_ops.reshape(intermediate_tensor, new_shape)
  
imports: import functools
  from typing import Any, Dict
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework.constant_op import constant
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import manip_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.trackable import base
label_desc: Use image node_id 1 for calling a global function with example usage: unshuffle_from_sc_to_cpu(t, num_sparse_cores, offset_in_shard, size_in_shard, shard_rotation) and returns: array_ops