code: def convert_to_size_dict(
      size,
      max_size: Optional[int] = None,
      default_to_square: bool = True,
      height_width_order: bool = True,
  ):
      # By default, if size is an int we assume it represents a tuple of (size, size).
      if isinstance(size, int) and default_to_square:
          if max_size is not None:
              raise ValueError(
                  "Cannot specify both size as an int, with default_to_square=True and max_size"
              )
          return {"height": size, "width": size}
      # In other configs, if size is an int and default_to_square is False, size represents the length of
      # the shortest edge after resizing.
      elif isinstance(size, int) and not default_to_square:
          size_dict = {"shortest_edge": size}
          if max_size is not None:
              size_dict["longest_edge"] = max_size
          return size_dict
      # Otherwise, if size is a tuple it's either (height, width) or (width, height)
      elif isinstance(size, (tuple, list)) and height_width_order:
          return {"height": size[0], "width": size[1]}
      elif isinstance(size, (tuple, list)) and not height_width_order:
          return {"height": size[1], "width": size[0]}
      elif size is None and max_size is not None:
          if default_to_square:
              raise ValueError(
                  "Cannot specify both default_to_square=True and max_size"
              )
          return {"longest_edge": max_size}
  
      raise ValueError(
          f"Could not convert size input to size dict: {size}"
      )
  
imports: import copy
  import json
  import os
  import warnings
  from io import BytesIO
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  import requests
  from .dynamic_module_utils import custom_object_save
  from .feature_extraction_utils import BatchFeature
  from .image_transforms import center_crop, normalize, rescale
  from .image_utils import ChannelDimension
  from .utils import IMAGE_PROCESSOR_NAME, PushToHubMixin, add_model_info_to_auto_map, cached_file, copy_func, download_url, is_offline_mode, is_remote_url, is_vision_available, logging
label_desc: Use image node_id 2 for calling a global function with example usage: convert_to_size_dict(size, max_size, default_to_square, height_width_order) and returns: dict, size_dict, dict, dict, dict