docstr: Move the shard tensor in the chunk.
  
  Args:
      device: the device to which the shard will move
      force_copy: if True, copy function is called mandatorily
docstr_tok: ["Move","the","shard","tensor","in","the","chunk",".","Args",":","device",":","the","device","to","which","the","shard","will","move","force_copy",":","if","True",",","copy","function","is","called","mandatorily"]
code: def shard_move(self, device: torch.device, force_copy: bool = False):
      """Move the shard tensor in the chunk.
  
      Args:
          device: the device to which the shard will move
          force_copy: if True, copy function is called mandatorily
      """
      # sanity check
      assert not self.is_gathered
      # when the current chunk is not synchronized with the optimizer
      # just use another way for the movement
      if not self.optim_sync_flag:
          assert (
              device.type == "cuda" or device.type == "npu"
          ), "each chunk should first be moved to CUDA"
          self.__paired_shard_move()
          self.optim_sync_flag = True
          return
  
      if device.type == "cuda" or device.type == "npu":
          assert (
              device == get_current_device()
          ), "can't move chunk to another device"
  
          if self.cuda_shard:
              return
  
          self.cuda_shard = self.cpu_shard.to(get_current_device())
  
          if not self.pin_memory:
              self.cpu_shard = None
      elif device.type == "cpu":
          if self.cuda_shard is None:
              return
  
          if self.pin_memory:
              if force_copy or not self.cpu_vis_flag:
                  self.cpu_shard.copy_(self.cuda_shard)
              # if cpu_shard has been visited
              # copy operation is not need
          else:
              self.cpu_shard = self.cuda_shard.cpu()
          self.cpu_vis_flag = True
          self.cuda_shard = None
      else:
          raise NotImplementedError
  
imports: from dataclasses import dataclass
  from enum import Enum
  from typing import Dict, List, Optional
  import torch
  import torch.distributed
  from torch.distributed import ProcessGroup
  from colossalai.utils import get_current_device
  from colossalai.utils.device import IS_NPU_AVAILABLE
label_desc: Use image node_id 13 for calling the Chunk obj's underlying member method code with example usage: obj.shard_move(device, force_copy) without return types