code: def adjust_gamma(
      img: Tensor, gamma: float, gain: float = 1
  ) -> Tensor:
      if not isinstance(img, torch.Tensor):
          raise TypeError("Input img should be a Tensor.")
  
      _assert_channels(img, [1, 3])
  
      if gamma < 0:
          raise ValueError("Gamma should be a non-negative real number")
  
      result = img
      dtype = img.dtype
      if not torch.is_floating_point(img):
          result = convert_image_dtype(result, torch.float32)
  
      result = (gain * result**gamma).clamp(0, 1)
  
      result = convert_image_dtype(result, dtype)
      return result
  
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 17 for calling a global function with example usage: adjust_gamma(img, gamma, gain) and returns: result