code: def init_graph(
      seed=None,
      log_device=False,
      num_cores=0,
      gpu_memory_fraction=0,
      soft_placement=True,
  ):
      """init_graph.
  
      Initialize a graph with specific parameters.
  
      Arguments:
          seed: `int`. Set the graph random seed.
          log_device: `bool`. Log device placement or not.
          num_cores: Number of CPU cores to be used. Default: All.
          gpu_memory_fraction: A value between 0 and 1 that indicates what
              fraction of the available GPU memory to pre-allocate for each
              process. 1 means to pre-allocate all of the GPU memory,
              0.5 means the process allocates ~50% of the available GPU
              memory. Default: Use all GPU's available memory.
          soft_placement: `bool`. Whether soft placement is allowed. If true,
              an op will be placed on CPU if:
                  1. there's no GPU implementation for the OP
                      or
                  2. no GPU devices are known or registered
                      or
                  3. need to co-locate with reftype input(s) which are from CPU.
      """
      if seed:
          tf.set_random_seed(seed)
      gs = tf.GPUOptions(
          per_process_gpu_memory_fraction=gpu_memory_fraction
      )
      config = tf.ConfigProto(
          log_device_placement=log_device,
          inter_op_parallelism_threads=num_cores,
          intra_op_parallelism_threads=num_cores,
          gpu_options=gs,
          allow_soft_placement=soft_placement,
      )
      tf.add_to_collection(tf.GraphKeys.GRAPH_CONFIG, config)
  
      return config
  
imports: from __future__ import division, print_function, absolute_import
  import tensorflow.compat.v1
  from .variables import variable
label_desc: Use image node_id 1 for calling a global function with example usage: init_graph(seed, log_device, num_cores, gpu_memory_fraction, soft_placement) and returns: config