code: def format_tensor(
      input,
      dtype: torch.dtype = torch.float32,
      device: Device = "cpu",
  ) -> torch.Tensor:
      """
      Helper function for converting a scalar value to a tensor.
  
      Args:
          input: Python scalar, Python list/tuple, torch scalar, 1D torch tensor
          dtype: data type for the input
          device: Device (as str or torch.device) on which the tensor should be placed.
  
      Returns:
          input_vec: torch tensor with optional added batch dimension.
      """
      device_ = make_device(device)
      if not torch.is_tensor(input):
          input = torch.tensor(input, dtype=dtype, device=device_)
  
      if input.dim() == 0:
          input = input.view(1)
  
      if input.device == device_:
          return input
  
      input = input.to(device=device)
      return input
  
imports: import copy
  import inspect
  import warnings
  from typing import Any, List, Optional, Tuple, TypeVar, Union
  import numpy
  import torch
  import torch.nn
  from ..common.datatypes import Device, make_device
label_desc: Use image node_id 1 for calling a global function with example usage: format_tensor(input, dtype, device) and returns: input, input