code: def replace_tensors_by_numpy_ndarrays(
      repr_ds: RepresentativeDataset, sess: session.Session
  ) -> RepresentativeDataset:
      """Replaces tf.Tensors in samples by their evaluated numpy arrays.
  
      Note: This should be run in graph mode (default in TF1) only.
  
      Args:
        repr_ds: Representative dataset to replace the tf.Tensors with their
          evaluated values. `repr_ds` is iterated through, so it may not be reusable
          (e.g. if it is a generator object).
        sess: Session instance used to evaluate tf.Tensors.
  
      Returns:
        The new representative dataset where each tf.Tensor is replaced by its
        evaluated numpy ndarrays.
      """
      new_repr_ds = []
      for sample in repr_ds:
          new_sample = {}
          for input_key, input_data in sample.items():
              # Evaluate the Tensor to get the actual value.
              if isinstance(input_data, core.Tensor):
                  input_data = input_data.eval(session=sess)
  
              new_sample[input_key] = input_data
  
          new_repr_ds.append(new_sample)
      return new_repr_ds
  
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 1 for calling a global function with example usage: replace_tensors_by_numpy_ndarrays(repr_ds, sess) and returns: new_repr_ds