code: def get_num_samples(repr_ds: RepresentativeDataset) -> Optional[int]:
      """Returns the number of samples if known.
  
      Args:
        repr_ds: Representative dataset.
  
      Returns:
        Returns the total number of samples in `repr_ds` if it can be determined
        without iterating the entier dataset. Returns None iff otherwise. When it
        returns None it does not mean the representative dataset is infinite or it
        is malformed; it simply means the size cannot be determined without
        iterating the whole dataset.
      """
      if isinstance(repr_ds, collections.abc.Sized):
          try:
              return len(repr_ds)
          except Exception as ex:  # pylint: disable=broad-except
              # There are some cases where calling __len__() raises an exception.
              # Handle this as if the size is unknown.
              logging.info(
                  "Cannot determine the size of the dataset (%s).", ex
              )
              return None
      else:
          return None
  
imports: import collections.abc
  import os
  from typing import Iterable, Mapping, Optional, Union
  import numpy
  from tensorflow.compiler.mlir.quantization.tensorflow import quantization_options_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.client import session
  from tensorflow.python.data.ops import readers
  from tensorflow.python.eager import context
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.lib.io import python_io
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.types import core
  from tensorflow.python.util import tf_export
label_desc: Use image node_id 2 for calling a global function with example usage: get_num_samples(repr_ds) and returns: None, len, None