code: def scale_image(
      x, ss: Tuple[int, int], crop_scale: bool = False
  ):  # annotations for torchscript
      """
      Pulled out of CrossViT.forward_features to bury conditional logic in a leaf node for FX tracing.
      Args:
          x (Tensor): input image
          ss (tuple[int, int]): height and width to scale to
          crop_scale (bool): whether to crop instead of interpolate to achieve the desired scale. Defaults to False
      Returns:
          Tensor: the "scaled" image batch tensor
      """
      H, W = x.shape[-2:]
      if H != ss[0] or W != ss[1]:
          if crop_scale and ss[0] <= H and ss[1] <= W:
              cu, cl = int(round((H - ss[0]) / 2.0)), int(
                  round((W - ss[1]) / 2.0)
              )
              x = x[:, :, cu : cu + ss[0], cl : cl + ss[1]]
          else:
              x = torch.nn.functional.interpolate(
                  x, size=ss, mode="bicubic", align_corners=False
              )
      return x
  
imports: from functools import partial
  from typing import List
  from typing import Tuple
  import torch
  import torch.hub
  import torch.nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import DropPath, to_2tuple, trunc_normal_, _assert
  from ._builder import build_model_with_cfg
  from ._features_fx import register_notrace_function
  from ._registry import register_model, generate_default_cfgs
  from .vision_transformer import Block
label_desc: Use image node_id 2 for calling a global function with example usage: scale_image(x, ss, crop_scale) and returns: x