code: def _sample_block(
      block: Block, n_samples: int, sort_key: SortKey
  ) -> Block:
      return BlockAccessor.for_block(block).sample(n_samples, sort_key)
  
imports: from typing import TYPE_CHECKING, List, Optional, Tuple, TypeVar, Union
  import numpy
  from ray.data._internal.block_list import BlockList
  from ray.data._internal.delegating_block_builder import DelegatingBlockBuilder
  from ray.data._internal.execution.interfaces import TaskContext
  from ray.data._internal.progress_bar import ProgressBar
  from ray.data._internal.push_based_shuffle import PushBasedShufflePlan
  from ray.data._internal.remote_fn import cached_remote_fn
  from ray.data._internal.shuffle import ShuffleOp, SimpleShufflePlan
  from ray.data.block import Block, BlockAccessor, BlockExecStats, BlockMetadata
  from ray.data.context import DataContext
  from ray.types import ObjectRef
label_desc: Use image node_id 3 for calling a global function with example usage: _sample_block(block, n_samples, sort_key) and returns: BlockAccessor