parameters: (org_instance, to_graph, scope="")
return_statement: return new_var
docstring: Given a `Variable` instance from one `Graph`, initializes and returns
      a copy of it from another `Graph`, under the specified scope
      (default `""`).
  
      Args:
      org_instance: A `Variable` from some `Graph`.
      to_graph: The `Graph` to copy the `Variable` to.
      scope: A scope for the new `Variable` (default `""`).
  
      Returns:
          The copied `Variable` from `to_graph`.
  
      Raises:
          TypeError: If `org_instance` is not a `Variable`.
docstring_summary: Given a `Variable` instance from one `Graph`, initializes and returns
      a copy of it from another `Graph`, under the specified scope
      (default `""`).
docstring_tokens: Given a Variable instance from one Graph initializes and returns a copy of it from another Graph under the specified scope ( default ) .
function: def copy_variable_to_graph(org_instance, to_graph, scope=""):
      """Given a `Variable` instance from one `Graph`, initializes and returns
      a copy of it from another `Graph`, under the specified scope
      (default `""`).
  
      Args:
      org_instance: A `Variable` from some `Graph`.
      to_graph: The `Graph` to copy the `Variable` to.
      scope: A scope for the new `Variable` (default `""`).
  
      Returns:
          The copied `Variable` from `to_graph`.
  
      Raises:
          TypeError: If `org_instance` is not a `Variable`.
      """
  
      if not isinstance(org_instance, Variable):
          raise TypeError(str(org_instance) + " is not a Variable")
  
      #The name of the new variable
      if scope != "":
          new_name = (scope + '/' +
                      org_instance.name[:org_instance.name.index(':')])
      else:
          new_name = org_instance.name[:org_instance.name.index(':')]
  
      #Get the collections that the new instance needs to be added to.
      #The new collections will also be a part of the given scope,
      #except the special ones required for variable initialization and
      #training.
      collections = []
      for name, collection in org_instance.graph._collections.items():
          if org_instance in collection:
              if (name == ops.GraphKeys.VARIABLES or
                  name == ops.GraphKeys.TRAINABLE_VARIABLES or
                  scope == ''):
                  collections.append(name)
              else:
                  collections.append(scope + '/' + name)
  
      #See if its trainable.
      trainable = (org_instance in org_instance.graph.get_collection(
          ops.GraphKeys.TRAINABLE_VARIABLES))
      #Get the initial value
      with org_instance.graph.as_default():
          temp_session = Session()
          init_value = temp_session.run(org_instance.initialized_value())
  
      #Initialize the new variable
      with to_graph.as_default():
          new_var = Variable(init_value,
                             trainable,
                             name=new_name,
                             collections=collections,
                             validate_shape=False)
  
      return new_var
function_tokens: def copy_variable_to_graph ( org_instance , to_graph , scope = "" ) : if not isinstance ( org_instance , Variable ) : raise TypeError ( str ( org_instance ) + " is not a Variable" ) #The name of the new variable if scope != "" : new_name = ( scope + '/' + org_instance . name [ : org_instance . name . index ( ':' ) ] ) else : new_name = org_instance . name [ : org_instance . name . index ( ':' ) ] #Get the collections that the new instance needs to be added to. #The new collections will also be a part of the given scope, #except the special ones required for variable initialization and #training. collections = [ ] for name , collection in org_instance . graph . _collections . items ( ) : if org_instance in collection : if ( name == ops . GraphKeys . VARIABLES or name == ops . GraphKeys . TRAINABLE_VARIABLES or scope == '' ) : collections . append ( name ) else : collections . append ( scope + '/' + name ) #See if its trainable. trainable = ( org_instance in org_instance . graph . get_collection ( ops . GraphKeys . TRAINABLE_VARIABLES ) ) #Get the initial value with org_instance . graph . as_default ( ) : temp_session = Session ( ) init_value = temp_session . run ( org_instance . initialized_value ( ) ) #Initialize the new variable with to_graph . as_default ( ) : new_var = Variable ( init_value , trainable , name = new_name , collections = collections , validate_shape = False ) return new_var