code: def adjust_contrast(img: Tensor, contrast_factor: float) -> Tensor:
      if contrast_factor < 0:
          raise ValueError(
              f"contrast_factor ({contrast_factor}) is not non-negative."
          )
  
      _assert_image_tensor(img)
  
      _assert_channels(img, [3, 1])
      c = get_dimensions(img)[0]
      dtype = (
          img.dtype if torch.is_floating_point(img) else torch.float32
      )
      if c == 3:
          mean = torch.mean(
              rgb_to_grayscale(img).to(dtype),
              dim=(-3, -2, -1),
              keepdim=True,
          )
      else:
          mean = torch.mean(
              img.to(dtype), dim=(-3, -2, -1), keepdim=True
          )
  
      return _blend(img, mean, contrast_factor)
  
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 14 for calling a global function with example usage: adjust_contrast(img, contrast_factor) and returns: _blend