code: def _cast_squeeze_out(
      img: Tensor,
      need_cast: bool,
      need_squeeze: bool,
      out_dtype: torch.dtype,
  ) -> Tensor:
      if need_squeeze:
          img = img.squeeze(dim=0)
  
      if need_cast:
          if out_dtype in (
              torch.uint8,
              torch.int8,
              torch.int16,
              torch.int32,
              torch.int64,
          ):
              # it is better to round before cast
              img = torch.round(img)
          img = img.to(out_dtype)
  
      return img
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import Tensor
  from torch.nn.functional import conv2d, grid_sample, interpolate, pad
label_desc: Use image node_id 27 for calling a global function with example usage: _cast_squeeze_out(img, need_cast, need_squeeze, out_dtype) and returns: img