code: def execute(cls, ctx, op: "GroupBySample"):
      out_df = op.outputs[0]
  
      if op.stage == OperandStage.map:
          in_data = ctx[op.inputs[0].key]
          in_data = np.sort(in_data)
          input_nsplits = np.copy(op.input_nsplits).tolist()
          pos_array = np.cumsum([0] + input_nsplits)
          poses = np.searchsorted(in_data, pos_array).tolist()
          for idx, (left, right) in enumerate(zip(poses, poses[1:])):
              ctx[op.outputs[0].key, (idx,)] = in_data[left:right]
      elif op.stage == OperandStage.reduce:
          in_indexes = list(op.iter_mapper_data(ctx))
          idx = np.sort(np.concatenate(in_indexes))
          if op.outputs[0].index[0] > 0:
              acc_nsplits = np.cumsum(op.input_nsplits)
              idx -= acc_nsplits[op.outputs[0].index[0] - 1]
          ctx[op.outputs[0].key] = idx
      elif op.stage == OperandStage.combine:
          in_data = ctx[op.inputs[0].key]
          idx = ctx[op.inputs[1].key]
          selection = op.groupby_params.get("selection")
          if selection:
              in_data = in_data[selection]
          ctx[op.outputs[0].key] = in_data.iloc[idx]
      else:
          in_data = ctx[op.inputs[0].key]
          weights = op.weights
          if isinstance(weights, ENTITY_TYPE):
              weights = ctx[weights.key]
          params = op.groupby_params.copy()
          selection = params.pop("selection", None)
  
          grouped = in_data.groupby(**params)
          if selection is not None:
              grouped = grouped[selection]
  
          result = pd.concat(
              [
                  sample_df
                  for sample_df in _sample_groupby_iter(
                      grouped,
                      in_data.index,
                      n=op.size,
                      frac=op.frac,
                      replace=op.replace,
                      weights=weights,
                      random_state=op.random_state,
                      errors=op.errors,
                  )
              ]
          )
          ctx[out_df.key] = result
  
imports: import copy
  import itertools
  import random
  from collections.abc import Iterable
  from typing import Optional, Sequence, Union
  import numpy
  import pandas
  from ...None import opcodes
  from ...core import ENTITY_TYPE, OutputType, get_output_types, recursive_tile
  from ...core.operand import OperandStage, MapReduceOperand
  from ...serialization.serializables import BoolField, DictField, Float32Field, KeyField, Int32Field, Int64Field, NDArrayField, StringField
  from ...tensor.operands import TensorShuffleProxy
  from ...tensor.random import RandomStateField
  from ...tensor.utils import gen_random_seeds
  from ...utils import has_unknown_shape
  from ..initializer import Series
  from ..operands import DataFrameOperandMixin, DataFrameOperand
  from ..utils import parse_index
label_desc: Use image node_id 8 for calling the GroupBySample obj's underlying member method code with example usage: obj.execute(cls, ctx, op) without return types