code: def _object_to_tensor(obj, device=None):
      f = io.BytesIO()
      paddle_pickle_dump(obj, f, protocol=2)
      byte_data = list(f.getvalue())
      byte_tensor = paddle.to_tensor(byte_data, dtype=paddle.int32)
      local_size = paddle.to_tensor([byte_tensor.numel()])
      if device is not None:
          byte_tensor = paddle_move_data_to_device(byte_tensor, device)
          local_size = paddle_move_data_to_device(local_size, device)
      return byte_tensor, local_size
  
file_path: fastNLP/fastNLP/core/drivers/paddle_driver/dist_utils.py
imports: import io
  import pickle
  import os
  from typing import Any, List
  import numpy
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
  from fastNLP.envs.env import FASTNLP_NO_SYNC
  from fastNLP.core.utils import paddle_move_data_to_device
label_desc: Use image node_id 4 for calling a global function with example usage: _object_to_tensor(obj, device) and returns: byte_tensor,  local_size