code: def variable(
      name,
      shape=None,
      dtype=None,
      initializer=None,
      regularizer=None,
      trainable=True,
      collections=None,
      caching_device=None,
      device=None,
      partitioner=None,
      custom_getter=None,
      use_resource=None,
      synchronization=variables.VariableSynchronization.AUTO,
      aggregation=variables.VariableAggregation.NONE,
  ):
      """Gets an existing variable with these parameters or creates a new one.
  
      Args:
        name: the name of the new or existing variable.
        shape: shape of the new or existing variable.
        dtype: type of the new or existing variable (defaults to `DT_FLOAT`).
        initializer: initializer for the variable if one is created.
        regularizer: a (Tensor -> Tensor or None) function; the result of applying
          it on a newly created variable will be added to the collection
          GraphKeys.REGULARIZATION_LOSSES and can be used for regularization.
        trainable: If `True` also add the variable to the graph collection
          `GraphKeys.TRAINABLE_VARIABLES` (see `tf.Variable`).
        collections: A list of collection names to which the Variable will be added.
          If None it would default to `tf.GraphKeys.GLOBAL_VARIABLES`.
        caching_device: Optional device string or function describing where the
          Variable should be cached for reading.  Defaults to the Variable's device.
        device: Optional device to place the variable. It can be an string or a
          function that is called to get the device for the variable.
        partitioner: Optional callable that accepts a fully defined `TensorShape`
          and dtype of the `Variable` to be created, and returns a list of
          partitions for each axis (currently only one axis can be partitioned).
        custom_getter: Callable that allows overwriting the internal get_variable
          method and has to have the same signature.
        use_resource: If `True` use a ResourceVariable instead of a Variable.
        synchronization: Indicates when a distributed a variable will be aggregated.
          Accepted values are constants defined in the class
          `tf.VariableSynchronization`. By default the synchronization is set to
          `AUTO` and the current `DistributionStrategy` chooses when to synchronize.
        aggregation: Indicates how a distributed variable will be aggregated.
          Accepted values are constants defined in the class
          `tf.VariableAggregation`.
  
      Returns:
        The created or existing variable.
      """
      collections = list(
          collections
          if collections is not None
          else [ops.GraphKeys.GLOBAL_VARIABLES]
      )
  
      # Remove duplicates
      collections = list(set(collections))
      getter = variable_scope.get_variable
      if custom_getter is not None:
          getter = functools.partial(
              custom_getter,
              reuse=variable_scope.get_variable_scope().reuse,
          )
      with ops.device(device or ""):
          return getter(
              name,
              shape=shape,
              dtype=dtype,
              initializer=initializer,
              regularizer=regularizer,
              trainable=trainable,
              collections=collections,
              caching_device=caching_device,
              partitioner=partitioner,
              use_resource=use_resource,
              synchronization=synchronization,
              aggregation=aggregation,
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import re
  from .arg_scope import add_arg_scope
  from tensorflow.core.protobuf import saver_pb2
  from tensorflow.python import pywrap_tensorflow
  from tensorflow.python.framework import device
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import resource_loader
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import saver
  from tensorflow.python.training import training_util
  from tensorflow.python.util.deprecation import deprecated
label_desc: Use image node_id 8 for calling a global function with example usage: variable(name, shape, dtype, initializer, regularizer, trainable, collections, caching_device, device, partitioner, custom_getter, use_resource, synchronization, aggregation) and returns: getter