code: def get_size_with_aspect_ratio(
      image_size: List[int], size: int, max_size: Optional[int] = None
  ):
      w, h = image_size
      if max_size is not None:
          min_original_size = float(min((w, h)))
          max_original_size = float(max((w, h)))
          if max_original_size / min_original_size * size > max_size:
              size = int(
                  round(
                      max_size * min_original_size / max_original_size
                  )
              )
  
      if (w <= h and w == size) or (h <= w and h == size):
          return (h, w)
  
      if w < h:
          ow = size
          oh = int(size * h / w)
      else:
          oh = size
          ow = int(size * w / h)
  
      return (oh, ow)
  
imports: import random
  from typing import List, Optional, Union
  import torch
  import torchvision.transforms
  import torchvision.transforms.functional
  from mmf.common.registry import registry
  from mmf.datasets.processors.processors import BaseProcessor
  from mmf.utils.box_ops import box_xyxy_to_cxcywh
  from torch import Tensor
label_desc: Use image node_id 3 for calling a global function with example usage: get_size_with_aspect_ratio(image_size, size, max_size) and returns: oh,  ow, h,  w