code: def flip_tensor(src_tensor, flip_direction):
      """flip tensor base on flip_direction.
  
      Args:
          src_tensor (Tensor): input feature map, shape (B, C, H, W).
          flip_direction (str): The flipping direction. Options are
            'horizontal', 'vertical', 'diagonal'.
  
      Returns:
          out_tensor (Tensor): Flipped tensor.
      """
      assert src_tensor.ndim == 4
      valid_directions = ["horizontal", "vertical", "diagonal"]
      assert flip_direction in valid_directions
      if flip_direction == "horizontal":
          out_tensor = torch.flip(src_tensor, [3])
      elif flip_direction == "vertical":
          out_tensor = torch.flip(src_tensor, [2])
      else:
          out_tensor = torch.flip(src_tensor, [2, 3])
      return out_tensor
  
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 7 for calling a global function with example usage: flip_tensor(src_tensor, flip_direction) and returns: out_tensor