parameters: (self, var, name, pass_through=False)
return_statement: return cache, cache_init, cache_reset
docstring: Helper function to create a worker cached copy of a Variable.
  
      This assigns the var (either a single Variable or a list of Variables) to
      local transient cache Variable(s). Note that if var is a list of Variables,
      the assignment is done sequentially to minimize the memory overheads.
      Also note that if pass_through is set to True, this does not create new
      Variables but simply return the input back.
  
      Args:
        var: A Variable or a list of Variables to cache.
        name: name of cached Variable.
        pass_through: when set to True, this simply pass through the var back
          through identity operator and does not actually creates a cache.
  
      Returns:
        Tuple consisting of following three entries:
        cache: the new transient Variable or list of transient Variables
          corresponding one-to-one with var.
        cache_init: op to initialize the Variable or the list of Variables.
        cache_reset: op to reset the Variable or the list of Variables to some
          default value.
docstring_summary: Helper function to create a worker cached copy of a Variable.
docstring_tokens: Helper function to create a worker cached copy of a Variable .
function: def _cached_copy(self, var, name, pass_through=False):
      """Helper function to create a worker cached copy of a Variable.
  
      This assigns the var (either a single Variable or a list of Variables) to
      local transient cache Variable(s). Note that if var is a list of Variables,
      the assignment is done sequentially to minimize the memory overheads.
      Also note that if pass_through is set to True, this does not create new
      Variables but simply return the input back.
  
      Args:
        var: A Variable or a list of Variables to cache.
        name: name of cached Variable.
        pass_through: when set to True, this simply pass through the var back
          through identity operator and does not actually creates a cache.
  
      Returns:
        Tuple consisting of following three entries:
        cache: the new transient Variable or list of transient Variables
          corresponding one-to-one with var.
        cache_init: op to initialize the Variable or the list of Variables.
        cache_reset: op to reset the Variable or the list of Variables to some
          default value.
      """
      if var is None:
        return None, None, None
      elif pass_through:
        cache = var
        cache_init = control_flow_ops.no_op()
        cache_reset = control_flow_ops.no_op()
      elif isinstance(var, variables.Variable):
        cache = WALSModel._transient_var(name=name)
        with ops.colocate_with(cache):
          cache_init = state_ops.assign(cache, var, validate_shape=False)
          cache_reset = state_ops.assign(cache, 1.0, validate_shape=False)
      else:
        assert isinstance(var, list)
        assert var
        cache = [
            WALSModel._transient_var(name="%s_shard_%d" % (name, i))
            for i in xrange(len(var))
        ]
        reset_ops = []
        for i, c in enumerate(cache):
          with ops.colocate_with(c):
            if i == 0:
              cache_init = state_ops.assign(c, var[i], validate_shape=False)
            else:
              with ops.control_dependencies([cache_init]):
                cache_init = state_ops.assign(c, var[i], validate_shape=False)
            reset_ops.append(state_ops.assign(c, 1.0, validate_shape=False))
        cache_reset = control_flow_ops.group(*reset_ops)
  
      return cache, cache_init, cache_reset
function_tokens: def _cached_copy ( self , var , name , pass_through = False ) : if var is None : return None , None , None elif pass_through : cache = var cache_init = control_flow_ops . no_op ( ) cache_reset = control_flow_ops . no_op ( ) elif isinstance ( var , variables . Variable ) : cache = WALSModel . _transient_var ( name = name ) with ops . colocate_with ( cache ) : cache_init = state_ops . assign ( cache , var , validate_shape = False ) cache_reset = state_ops . assign ( cache , 1.0 , validate_shape = False ) else : assert isinstance ( var , list ) assert var cache = [ WALSModel . _transient_var ( name = "%s_shard_%d" % ( name , i ) ) for i in xrange ( len ( var ) ) ] reset_ops = [ ] for i , c in enumerate ( cache ) : with ops . colocate_with ( c ) : if i == 0 : cache_init = state_ops . assign ( c , var [ i ] , validate_shape = False ) else : with ops . control_dependencies ( [ cache_init ] ) : cache_init = state_ops . assign ( c , var [ i ] , validate_shape = False ) reset_ops . append ( state_ops . assign ( c , 1.0 , validate_shape = False ) ) cache_reset = control_flow_ops . group ( * reset_ops ) return cache , cache_init , cache_reset