code: def test_topk(self):
      class MyModule(Module):
          def forward(self, x):
              return torch.topk(x, 3)
  
      ops_9 = [
          {
              "op_name": "TopK",
              "attributes": [
                  {"name": "axis", "i": -1, "type": 2},
                  {"name": "k", "i": 3, "type": 2},
              ],
          }
      ]
      ops_10 = [
          {"op_name": "Constant"},
          {
              "op_name": "TopK",
              "attributes": [{"name": "axis", "i": -1, "type": 2}],
          },
      ]
      ops = {9: ops_9, 10: ops_10}
      x = torch.arange(1.0, 6.0, requires_grad=True)
      check_onnx_opsets_operator(
          MyModule(), x, ops, opset_versions=[9, 10]
      )
  
      # test with dynamic k
      class MyModuleDynamic(torch.jit.ScriptModule):
          @torch.jit.script_method
          def forward(self, input, k):
              return torch.topk(input, k)
  
      ops_10 = [
          {
              "op_name": "Constant",
              "attributes": [{"name": "value", "type": 4}],
          },
          {"op_name": "Reshape"},
          {
              "op_name": "TopK",
              "attributes": [{"name": "axis", "i": -1, "type": 2}],
          },
      ]
      ops = {10: ops_10}
      x = torch.arange(1.0, 6.0, requires_grad=True)
      k = torch.tensor(3)
      module = MyModuleDynamic()
      check_onnx_opsets_operator(
          module, (x, k), ops, opset_versions=[10]
      )
  
imports: import io
  import itertools
  import onnx
  import pytorch_test_common
  import torch
  import torch.onnx
  from torch.nn import Module
  from torch.onnx import producer_name, producer_version
  from torch.onnx._globals import GLOBALS
  from torch.testing._internal import common_utils
label_desc: Use image node_id 2 for calling the TestONNXOpset obj's underlying member method code with example usage: obj.test_topk() and returns: torch, torch