code: def _imread(
      image_path,
      rgb: bool = True,
      target_size=None,
      resize_factor=None,
      preserve_aspect_ratio=False,
      interpolation: str = "bilinear",
  ) -> Tensor:
      if target_size is not None:
          _check_target_size(target_size)
  
      # if not isinstance(channels, int) or channels not in [1, 3]:
      #     raise ValueError("channels must be an integer - 1 (Grayscale) or 3 (RGB)")
  
      interpolation_methods = {
          "nearest": 0,
          "0": 0,
          0: 0,  # 0
          "bilinear": 1,
          "1": 1,
          1: 1,  # 1
          "bicubic": 2,
          "2": 2,
          2: 2,  # 2
          "area": 3,
          "3": 3,
          3: 3,  # 3
      }
  
      if interpolation not in interpolation_methods:
          raise ValueError(
              "Specify a valid interpolation type - area/nearest/bicubic/bilinear"
          )
  
      if exists(image_path):
          tens = _read_image(image_path)  # returns RGB
  
      # TODO: Create URL validator
      elif image_path.startswith(('http://", "https://')):
          # Returns RGB image
          tens = _url_to_image(image_path)
  
          # If the URL is valid, but no image at that URL, NoneType is returned
          if tens is None:
              raise ValueError(
                  "The URL specified does not point to an image"
              )
  
      else:
          raise ValueError("Specify either a valid URL or filepath")
  
      # try:
      #     # Returns RGB image
      #     tens = _url_to_image(image_path)
  
      #     # If the URL is valid, but no image at that URL, NoneType is returned
      #     if tens is None:
      #         raise ValueError("The URL specified does not point to an image")
  
      #     # return tens
  
      # # If the URL is invalid
      # except (Exception, URLError):
      #     if exists(image_path):
      #         tens = _read_image(image_path) # returns RGB
  
      #     else:
      #         raise ValueError("Specify either a valid URL or filepath")
  
      if target_size is not None or resize_factor is not None:
          # Enforce a Tensor is passed to resize()
          to_tensor(tens, cspace="rgb")
          tens = resize(
              tens,
              target_size,
              resize_factor=resize_factor,
              preserve_aspect_ratio=preserve_aspect_ratio,
              interpolation=interpolation,
          )
  
      # If `rgb=False`, then we assume that BGR is expected
      if not rgb:
          tens = rgb2bgr(tens)
          # We need to convert back to tensor
          return to_tensor(tens, cspace="bgr")
  
      return to_tensor(tens, cspace="rgb")
  
file_path: caer/caer/io/io.py
imports: import cv2
  import numpy
  from urllib.request import urlopen
  from .resize import resize
  from ..coreten import to_tensor, Tensor
  from ..color import rgb2bgr, to_bgr
  from ..path import exists
  from .._internal import _check_target_size
  from typing import Tuple, Optional, Union
label_desc: Use image node_id 2 for calling a global function with example usage: _imread(image_path, rgb, target_size, resize_factor, preserve_aspect_ratio, interpolation) and returns: to_tensor, to_tensor