code: def test_float_input_large_k_forward(
      seed, ishape, k, base_axis, ctx, fname
  ):
      import nnabla as nn
  
      def generate_sparse_float_input(rng, ishape):
          total_elements = np.prod(ishape)
          # Generate a sparse input array where k elements have positive float values,
          # and make the result of elements 0
          unique_indices = rng.choice(
              range(1, total_elements), k, replace=False
          )
          values = np.linspace(0.1, 1.0, k)
          np.random.shuffle(values)  # Shuffle the values
          sparse_input = np.zeros(total_elements, dtype=np.float32)
          sparse_input[unique_indices] = values
          sparse_input = sparse_input.reshape(ishape)
          return sparse_input
  
      rng = np.random.RandomState(seed)
      x = generate_sparse_float_input(rng, ishape)
      in_data = nn.Variable(shape=ishape)
      in_data.d = x
      with nn.context_scope(ctx), nn.auto_forward():
          topk_data, topk_index = F.top_k_data(
              in_data,
              k,
              reduce=True,
              with_index=True,
              base_axis=base_axis,
          )
  
      assert topk_data.d[0][-1] != 0.0
      assert topk_index.d[0][-1] != 0.0
  
      # forward again with a new Variable of the same value
      in_data2 = nn.Variable(shape=ishape)
      in_data2.d = x
  
      with nn.context_scope(ctx), nn.auto_forward():
          topk_data2, topk_index2 = F.top_k_data(
              in_data2,
              k,
              reduce=True,
              with_index=True,
              base_axis=base_axis,
          )
  
      assert topk_data2.d[0][-1] != 0.0
      assert topk_index2.d[0][-1] != 0.0
  
file_path: nnabla/python/test/function/test_top_k_data.py
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context, function_tester
label_desc: Use image node_id 6 for calling a global function with example usage: test_float_input_large_k_forward(seed, ishape, k, base_axis, ctx, fname) and returns: sparse_input