class_docstr: Move tensor to device.
  
  Parameters
  ----------
  device: torch.device
      Device to move to.
  non_blocking: bool
      Asynchronous if copying from CPU to GPU.
code: def generate_code(self) -> Callable:
      def to_device(inp, dst):
          if len(inp.shape) == 4:
              if inp.is_contiguous(memory_format=ch.channels_last):
                  dst = dst.reshape(
                      inp.shape[0],
                      inp.shape[2],
                      inp.shape[3],
                      inp.shape[1],
                  )
                  dst = dst.permute(0, 3, 1, 2)
          dst = dst[: inp.shape[0]]
          dst.copy_(inp, non_blocking=self.non_blocking)
          return dst
  
      return to_device
  
imports: import torch
  import numpy
  from typing import Callable, Optional, Tuple
  from ..pipeline.allocation_query import AllocationQuery
  from ..pipeline.operation import Operation
  from ..pipeline.state import State
  from dataclasses import replace
label_desc: Use image node_id 2 for calling the ToDevice obj's underlying member method code with example usage: obj.generate_code() and returns: to_device, dst