code: def var_and_name_scope(names):
    
    # pylint: disable=protected-access
    if not names:
      yield None, None
    else:
      name, var_scope = names
      with tf.name_scope(name) as scope:
        # TODO(eiderman): This is a workaround until the variable_scope updates land
        # in a TF release.
        old_vs = tf.get_variable_scope()
        if var_scope is None:
          count = len(name.split('/'))
          scoped_name = '/'.join(scope.split('/')[-count - 1:-1])
          full_name = (old_vs.name + '/' + scoped_name).lstrip('/')
        else:
          full_name = var_scope.name
  
        vs_key = tf.get_collection_ref(variable_scope._VARSCOPE_KEY)
        try:
          # TODO(eiderman): Remove this hack or fix the full file.
          try:
            vs_key[0] = tf.VariableScope(
                old_vs.reuse,
                name=full_name,
                initializer=old_vs.initializer,
                regularizer=old_vs.regularizer,
                caching_device=old_vs.caching_device)
          except AttributeError:
            vs_key[0] = variable_scope._VariableScope(
                old_vs.reuse,
                name=full_name,
                initializer=old_vs.initializer)
  
          vs_key[0].name_scope = scope
          yield scope, vs_key[0]
        finally:
          vs_key[0] = old_vs
docs: Creates a variable scope and a name scope.
  
    If a variable_scope is provided, this will reenter that variable scope.
    However, if none is provided then the variable scope will match the generated
    part of the name scope.
  
    Args:
      names: A tuple of name_scope, variable_scope or None.
    Yields:
      The result of name_scope and variable_scope as a tuple.