code: def test_top_k(self, X, flatten_indices, seed, gc, dc):
      X = X.astype(dtype=np.float32)
      np.random.seed(seed)
      # `k` can be larger than the total size
      k = np.random.randint(1, X.shape[-1] + 4)
  
      output_list = ["Values", "Indices"]
      if flatten_indices:
          output_list.append("FlattenIndices")
      op = core.CreateOperator(
          "TopK", ["X"], output_list, k=k, device_option=gc
      )
  
      def bind_ref(X_loc):
          return self.top_k_ref(X_loc, k, flatten_indices)
  
      self.assertReferenceChecks(gc, op, [X], bind_ref)
      self.assertDeviceChecks(dc, op, [X], [0])
  
file_path: pytorch/caffe2/python/operator_test/top_k_test.py
imports: import hypothesis.strategies
  import numpy
  from caffe2.python import core
  from hypothesis import given, settings
  import caffe2.python.hypothesis_test_util
  import caffe2.python.serialized_test.serialized_test_util
label_desc: Use image node_id 2 for calling the TestTopK obj's underlying member method code with example usage: obj.test_top_k(X, flatten_indices, seed, gc, dc) and returns: self