code: def rechunk(
      tensor: Tensor, chunk_size: chunk_size_type, reassign_worker=False
  ) -> Tensor:
      if (
          not any(np.isnan(s) for s in tensor.shape)
          and not tensor.is_coarse()
      ):
          if not has_unknown_shape(tensor):
              # do client check only when tensor has no unknown shape,
              # otherwise, recalculate chunk_size in `tile`
              chunk_size = get_nsplits(
                  tensor, chunk_size, tensor.dtype.itemsize
              )
              if chunk_size == tensor.nsplits:
                  return tensor
  
      op = TensorRechunk(
          chunk_size=chunk_size,
          reassign_worker=reassign_worker,
          dtype=tensor.dtype,
          sparse=tensor.issparse(),
      )
      return op(tensor)
  
file_path: mars/mars/tensor/rechunk/rechunk.py
imports: import numpy
  from ...None import opcodes
  from ...serialization.serializables import AnyField
  from ...utils import has_unknown_shape
  from ..core import Tensor
  from ..datasource import tensor
  from ..operands import TensorOperand, TensorOperandMixin
  from ..utils import calc_sliced_size
  from .core import chunk_size_type, get_nsplits, gen_rechunk_infos
label_desc: Use image node_id 1 for calling a global function with example usage: rechunk(tensor, chunk_size, reassign_worker) and returns: op, tensor