code: def format_for_plotting(tensor):
      """Formats the shape of tensor for plotting.
  
      Tensors typically have a shape of :math:`(N, C, H, W)` or :math:`(C, H, W)`
      which is not suitable for plotting as images. This function formats an
      input tensor :math:`(H, W, C)` for RGB and :math:`(H, W)` for mono-channel
      data.
  
      Args:
          tensor (torch.Tensor, torch.float32): Image tensor
  
      Shape:
          Input: :math:`(N, C, H, W)` or :math:`(C, H, W)`
          Output: :math:`(H, W, C)` or :math:`(H, W)`, respectively
  
      Return:
          torch.Tensor (torch.float32): Formatted image tensor (detached)
  
      Note:
          Symbols used to describe dimensions:
              - N: number of images in a batch
              - C: number of channels
              - H: height of the image
              - W: width of the image
  
      """
  
      has_batch_dimension = len(tensor.shape) == 4
      formatted = tensor.clone()
  
      if has_batch_dimension:
          formatted = tensor.squeeze(0)
  
      if formatted.shape[0] == 1:
          return formatted.squeeze(0).detach()
      else:
          return formatted.permute(1, 2, 0).detach()
  
file_path: flashtorch/flashtorch/utils/__init__.py
imports: from PIL import Image
  import torchvision.transforms
  import torchvision.transforms.functional
  from .imagenet import *
label_desc: Use image node_id 5 for calling a global function with example usage: format_for_plotting(tensor) and returns: formatted, formatted