def set_pooling_options(opts, pooling_options=None):
  """Set the IPU pooling compilation options for the session.

  .. code-block:: python

      # Set "poolUseIntrospectiveMapping" flag to "false"
      opts = create_ipu_config()
      opts = set_pooling_options(opts,
          pooling_options={"poolUseIntrospectiveMapping": "false"})
      ipu.utils.configure_ipu_system(opts)
      with tf.Session() as s:
        ...

  Args:
    opts: An IpuOptions session control protobuf.
    pooling_options: A dictionary of Poplar option flags for the pooling
      operation.

  Returns:
    The IpuOptions configuration protobuf, with pooling options set.
  """
  if pooling_options:
    if not isinstance(pooling_options, dict):
      raise Exception("`pooling_options` must be a dictionary")

    for (option_name, value) in pooling_options.items():
      opt = opts.pooling_options.add()
      opt.option = option_name
      opt.value = value

  return opts