code: def discrete_grid(dim: Integer, num: int):
      """Build discretized real grid"""
      grid = real_grid(dim, num)
  
      _, b = dim.interval()
  
      discrete_grid = [int(numpy.round(grid[0]))]
      for v in grid[1:]:
          int_v = int(numpy.round(v))
          if int_v <= discrete_grid[-1]:
              int_v = discrete_grid[-1] + 1
  
          if int_v > b:
              log.warning(
                  f"Cannot list {num} discrete values for {dim.name}. "
                  "Will use {len(discrete_grid)} points instead."
              )
              break
  
          discrete_grid.append(int_v)
  
      return discrete_grid
  
imports: from __future__ import annotations
  import itertools
  import logging
  import numpy
  from orion.algo.base import BaseAlgorithm
  from orion.algo.space import Categorical, Dimension, Fidelity, Integer, Real, Space
  from orion.core.utils import format_trials
label_desc: Use image node_id 4 for calling a global function with example usage: discrete_grid(dim, num) and returns: discrete_grid