code: def safely_set_viewless_tensor_data(tensor, new_data_tensor):
      """Safely set tensor's '.data' field.
  
      Check first that the tensor is viewless (i.e., '._base' not set). If not,
      raise an exception.
      """
      assert_viewless_tensor(
          tensor,
          extra_msg="FYI, tensor._base has shape %s, and new_data_tensor has shape %s."
          % (
              "--" if tensor._base is None else tensor._base.shape,
              new_data_tensor.shape,
          ),
      )
      tensor.data = new_data_tensor
  
imports: import math
  import operator
  from functools import reduce
  import torch
  from megatron.core import parallel_state
  from megatron.core.dist_checkpointing.mapping import ShardedTensor
label_desc: Use image node_id 9 for calling a global function with example usage: safely_set_viewless_tensor_data(tensor, new_data_tensor) without return types