code: def _topk_min(input: Tensor, orig_kval: int, axis: int) -> int:
      """
      ONNX spec requires the k-value to be less than or equal to the number of inputs along
      provided dim. Certain models use the number of elements along a particular axis instead of K
      if K exceeds the number of elements along that axis. Previously, python's min() function was
      used to determine whether to use the provided k-value or the specified dim axis value.
  
      However, in cases where the model is being exported in tracing mode, python min() is
      static causing the model to be traced incorrectly and eventually fail at the topk node.
      In order to avoid this situation, in tracing mode, torch.min() is used instead.
  
      Args:
          input (Tensor): The original input tensor.
          orig_kval (int): The provided k-value.
          axis(int): Axis along which we retrieve the input size.
  
      Returns:
          min_kval (int): Appropriately selected k-value.
      """
      if not torch.jit.is_tracing():
          return min(orig_kval, input.size(axis))
      axis_dim_val = torch._shape_as_tensor(input)[axis].unsqueeze(0)
      min_kval = torch.min(
          torch.cat(
              (
                  torch.tensor([orig_kval], dtype=axis_dim_val.dtype),
                  axis_dim_val,
              ),
              0,
          )
      )
      return _fake_cast_onnx(min_kval)
  
imports: import math
  from collections import OrderedDict
  from typing import Dict, List, Optional, Tuple
  import torch
  from torch import nn, Tensor
  from torch.nn import functional
  from torchvision.ops import complete_box_iou_loss, distance_box_iou_loss, FrozenBatchNorm2d, generalized_box_iou_loss
label_desc: Use image node_id 5 for calling a global function with example usage: _topk_min(input, orig_kval, axis) and returns: _fake_cast_onnx, min