def modify_config(pipeline_config):
  """Modifies pipeline config to build the correct graph for TPU."""
  # faster_rcnn.use_static_shapes and faster_rcnn.use_static_shapes_for_eval
  # are set to True in order for detection_model.use_static_shapes to be True.
  # We need to set this so that clip_to_window in _predict_first_stage
  # can work on TPU. However as a side-effect, the flag forces the use of
  # padded version of NMS.
  pipeline_config.model.faster_rcnn.use_static_shapes = True
  pipeline_config.model.faster_rcnn.use_static_shapes_for_eval = True
  pipeline_config.model.faster_rcnn.use_matmul_crop_and_resize = True
  pipeline_config.model.faster_rcnn.clip_anchors_to_image = True
  return pipeline_config