def set_ipu_model_options(opts,
                          compile_ipu_code=True,
                          tiles_per_ipu=None,
                          ipu_model_version="ipu2"):
  """Set the IPU Model options.

  Args:
    compile_ipu_code: Whether or not to actually compile real IPU code for
      modelling.
    tiles_per_ipu: The number of tiles per IPU Model device.
    ipu_model_version: Specify the IPU version to be used by the IPU Model.
      Must be one of "ipu1" or "ipu2" (default).

  Returns:
    The IpuOptions configuration protobuf, with IPU model options set.
  """
  opts.ipu_model_config.compile_ipu_code = compile_ipu_code
  if tiles_per_ipu:
    opts.ipu_model_config.tiles_per_ipu = tiles_per_ipu
  opts.ipu_model_config.ipu_model_version = ipu_model_version

  return opts