code: def get_size_with_aspect_ratio(
      image_size, size, max_size=None
  ) -> Tuple[int, int]:
      """
      Computes the output image size given the input image size and the desired output size.
  
      Args:
          image_size (`Tuple[int, int]`):
              The input image size.
          size (`int`):
              The desired output size.
          max_size (`int`, *optional*):
              The maximum allowed output size.
      """
      height, width = image_size
      if max_size is not None:
          min_original_size = float(min((height, width)))
          max_original_size = float(max((height, width)))
          if max_original_size / min_original_size * size > max_size:
              size = int(
                  round(
                      max_size * min_original_size / max_original_size
                  )
              )
  
      if (height <= width and height == size) or (
          width <= height and width == size
      ):
          return height, width
  
      if width < height:
          ow = size
          oh = int(size * height / width)
      else:
          oh = size
          ow = int(size * width / height)
      return (oh, ow)
  
imports: import pathlib
  from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  from ...feature_extraction_utils import BatchFeature
  from ...image_processing_utils import BaseImageProcessor, get_size_dict
  from ...image_transforms import PaddingMode, center_to_corners_format, corners_to_center_format, pad, rescale, resize, rgb_to_id, to_channel_dimension_format
  from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, AnnotationFormat, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_batched, is_scaled_image, to_numpy_array, valid_images, validate_annotations
  from ...utils import is_flax_available, is_jax_tensor, is_tf_available, is_tf_tensor, is_torch_available, is_torch_tensor, is_torchvision_available, is_vision_available, logging
  from ...utils.generic import TensorType
label_desc: Use image node_id 1 for calling a global function with example usage: get_size_with_aspect_ratio(image_size, size, max_size) and returns: oh,  ow, height,  width