code: def count_samples_in_shard(shard, pipeline):
      #
      # We count the length of the dataset
      # We are not using __len__ since it might not be implemented
      count = 0
      for _ in from_shard(shard, pipeline):
          count += 1
  
      return count
  
imports: from functools import partial
  from typing import Callable, List, Mapping
  from os import SEEK_END, path
  import numpy
  from time import sleep
  import ctypes
  from multiprocessing import shared_memory, cpu_count, Queue, Process, Value
  from tqdm import tqdm
  from tqdm.contrib.concurrent import thread_map
  from .utils import chunks, is_power_of_2
  from .fields.base import Field
  from .memory_allocator import MemoryAllocator
  from .types import TYPE_ID_HANDLER, get_metadata_type, HeaderType, FieldDescType, CURRENT_VERSION, ALLOC_TABLE_TYPE
label_desc: Use image node_id 2 for calling a global function with example usage: count_samples_in_shard(shard, pipeline) and returns: count