code: def constant(name, value, dtype, hide_batch_size=True):
      """Create constant variable with given data.
  
      This function helps to create constants variable with
      given numpy.ndarray data.
  
      Args:
          name: variable name
  
          value: numpy.ndarray the value of constant
  
          dtype: the type of constant
  
          hide_batch_size: If set the first dimenstion as unknown, the explicit
                           batch size may cause some error in paddle. For example,
                           when the value has a shape of (batch_size, dim1, dim2),
                           it will return a variable with shape (-1, dim1, dim2).
  
      Return:
          A tuple contain the constant variable and the constant
          variable initialize function.
  
      Examples:
          .. code-block:: python
  
              import paddle.fluid as fluid
              place = fluid.CPUPlace()
              exe = fluid.Executor(place)
              constant_var, constant_var_init = constant(name="constant",
                                value=np.array([5.0],
                                dtype="float32"))
              exe.run(fluid.default_startup_program())
              # Run After default startup
              constant_var_init(place)
  
      """
      if not isinstance(value, np.ndarray):
          raise TypeError("value should be Numpy array.")
  
      value = value.astype(dtype)
      data = L.create_global_var(
          shape=value.shape,
          value=0,
          dtype=value.dtype,
          name=name,
          persistable=True,
      )
      data.stop_gradient = True
  
      if hide_batch_size:
          shape = list(value.shape)
          shape[0] = -1
          data.desc.set_shape(shape)
  
      def initializer(place):
          if isinstance(place, fluid.CUDAPlace):
              pass
          elif isinstance(place, fluid.CUDAPinnedPlace):
              pass
          elif isinstance(place, fluid.CPUPlace):
              pass
          else:
              raise TypeError(
                  "The input of initializer is not in"
                  " [fluid.CUDAPlace, fluid.CPUPlace, fluid.CUDAPinnedPlace]"
              )
          var = fluid.global_scope().var(data.name).get_tensor()
          var.set(value, place)
  
      return data, initializer
  
file_path: PGL/legacy/pgl/utils/paddle_helper.py
imports: import warnings
  import numpy
  import paddle
  from paddle.fluid import core
  import paddle.fluid
  import paddle.fluid.layer_helper
  import paddle.fluid.layers
  from pgl.utils.logger import log
label_desc: Use image node_id 2 for calling a global function with example usage: constant(name, value, dtype, hide_batch_size) and returns: data,  initializer