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
Safely set tensor's '.data' field.

    Check first that the tensor is viewless (i.e., '._base' not set). If not,
    raise an exception.
    
training/DeepSpeed-Domino/domino/utils.py