code: def aligned_bilinear(tensor: Tensor, factor: int) -> Tensor:
      """aligned bilinear, used in original implement in CondInst:
  
      https://github.com/aim-uofa/AdelaiDet/blob/\
      c0b2092ce72442b0f40972f7c6dda8bb52c46d16/adet/utils/comm.py#L23
      """
  
      assert tensor.dim() == 4
      assert factor >= 1
      assert int(factor) == factor
  
      if factor == 1:
          return tensor
  
      h, w = tensor.size()[2:]
      tensor = F.pad(tensor, pad=(0, 1, 0, 1), mode="replicate")
      oh = factor * h + 1
      ow = factor * w + 1
      tensor = F.interpolate(
          tensor, size=(oh, ow), mode="bilinear", align_corners=True
      )
      tensor = F.pad(
          tensor, pad=(factor // 2, 0, factor // 2, 0), mode="replicate"
      )
  
      return tensor[:, :, : oh - 1, : ow - 1]
  
imports: from functools import partial
  from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from mmengine.utils import digit_version
  from six.moves import map, zip
  from torch import Tensor
  from torch.autograd import Function
  from torch.nn import functional
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import BaseBoxes, get_box_type, stack_boxes
  from mmdet.structures.mask import BitmapMasks, PolygonMasks
  from mmdet.utils import OptInstanceList
label_desc: Use image node_id 22 for calling a global function with example usage: aligned_bilinear(tensor, factor) and returns: tensor, tensor