code: def _check_chunk_size(reduced, chunk_size):  # pragma: no cover
      """Checks chunk is a sequence of expected size or a tuple of same"""
      if reduced is None:
          return
      is_tuple = isinstance(reduced, tuple)
      if not is_tuple:
          reduced = (reduced,)
      if any(
          isinstance(r, tuple) or not hasattr(r, "__iter__")
          for r in reduced
      ):
          raise TypeError(
              "reduce_func returned %r. "
              "Expected sequence(s) of length %d."
              % (reduced if is_tuple else reduced[0], chunk_size)
          )
      if any(_num_samples(r) != chunk_size for r in reduced):
          actual_size = tuple(_num_samples(r) for r in reduced)
          raise ValueError(
              "reduce_func returned object of length %s. "
              "Expected same length as input: %d."
              % (
                  actual_size if is_tuple else actual_size[0],
                  chunk_size,
              )
          )
  
imports: from functools import partial
  import numpy
  from ....None import opcodes
  from ....None import options
  from ....core import recursive_tile
  from ....core.operand import OperandStage
  from ....serialization.serializables import KeyField, BoolField, DictField, Int64Field, AnyField
  from ....tensor.core import TensorOrder
  from ....tensor.merge import TensorConcatenate
  from ....tensor.array_utils import as_same_device, device, get_array_module
  from ....utils import has_unknown_shape, ensure_own_data
  from ...utils import gen_batches, get_chunk_n_rows
  from ...utils.validation import _num_samples
  from .core import PairwiseDistances
label_desc: Use image node_id 2 for calling a global function with example usage: _check_chunk_size(reduced, chunk_size) without return types