code: def get_image_num_channels(img: Any) -> int:
      if _is_pil_image(img):
          if hasattr(img, "getbands"):
              return len(img.getbands())
          else:
              return img.channels
      raise TypeError(f"Unexpected type {type(img)}")
  
imports: import numbers
  from typing import Any, Dict, List, Literal, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from PIL import Image, ImageEnhance, ImageOps
label_desc: Use image node_id 4 for calling a global function with example usage: get_image_num_channels(img) and returns: len, img