parameters: (
      shape, dtype, shared_name, name, graph_mode, extra_handle_data=None)
docstring: Create a new variable handle, optionally copying in `extra_handle_data`.
docstring_summary: Create a new variable handle, optionally copying in `extra_handle_data`.
docstring_tokens: Create a new variable handle optionally copying in extra_handle_data .
function: def variable_handle_from_shape_and_dtype(
      shape, dtype, shared_name, name, graph_mode, extra_handle_data=None):
    """Create a new variable handle, optionally copying in `extra_handle_data`."""
    container = ops.get_default_graph()._container  # pylint: disable=protected-access
    if container is None:
      container = ""
    handle = gen_resource_variable_ops.var_handle_op(shape=shape, dtype=dtype,
                                                     shared_name=shared_name,
                                                     name=name,
                                                     container=container)
    if extra_handle_data is None:
      extra_handle_data = handle
    if graph_mode:
      full_handle_data = _combine_handle_data(handle, extra_handle_data)
      _set_handle_shapes_and_types(handle, full_handle_data, graph_mode)
      return handle
    else:
      # We do not want two distinct ResourceVariable objects for the same
      # underlying resource in the runtime.
      # When in eager mode, explicitly ensure so here. When in graph mode, it's
      # ensured by always generating different variable names.
      exists = gen_resource_variable_ops.var_is_initialized_op(handle)
  
      # We create an assert Op instead of checking right away in order to be
      # compatible with ASYNC execution mode. Further, since not all devices
      # support string tensors, we encode the assertion string in the Op name
      gen_logging_ops._assert(  # pylint: disable=protected-access
          math_ops.logical_not(exists), [exists], name="EagerVariableNameReuse")
  
      with context.graph_mode(), ops.Graph().as_default() as graph:
        h = gen_resource_variable_ops.var_handle_op(shape=shape, dtype=dtype,
                                                    shared_name=shared_name,
                                                    name=name,
                                                    container=container)
  
        # Tensor._handle_data contains information for the shape-inference code to
        # know the shape and dtype of the variable pointed to by a handle. Since
        # shape inference doesn't run in eager mode we copy this data here for
        # when the handle is captured by an eager mode function.
        # pylint: disable=protected-access
        full_handle_data = _combine_handle_data(h, extra_handle_data)
        _set_handle_shapes_and_types(handle, full_handle_data, graph_mode)
        # pylint: enable=protected-access
      # Clean up op->graph->op reference cycles.
      ops.dismantle_graph(graph)
      return handle
function_tokens: def variable_handle_from_shape_and_dtype ( shape , dtype , shared_name , name , graph_mode , extra_handle_data = None ) : container = ops . get_default_graph ( ) . _container # pylint: disable=protected-access if container is None : container = "" handle = gen_resource_variable_ops . var_handle_op ( shape = shape , dtype = dtype , shared_name = shared_name , name = name , container = container ) if extra_handle_data is None : extra_handle_data = handle if graph_mode : full_handle_data = _combine_handle_data ( handle , extra_handle_data ) _set_handle_shapes_and_types ( handle , full_handle_data , graph_mode ) return handle else : # We do not want two distinct ResourceVariable objects for the same # underlying resource in the runtime. # When in eager mode, explicitly ensure so here. When in graph mode, it's # ensured by always generating different variable names. exists = gen_resource_variable_ops . var_is_initialized_op ( handle ) # We create an assert Op instead of checking right away in order to be # compatible with ASYNC execution mode. Further, since not all devices # support string tensors, we encode the assertion string in the Op name gen_logging_ops . _assert ( # pylint: disable=protected-access math_ops . logical_not ( exists ) , [ exists ] , name = "EagerVariableNameReuse" ) with context . graph_mode ( ) , ops . Graph ( ) . as_default ( ) as graph : h = gen_resource_variable_ops . var_handle_op ( shape = shape , dtype = dtype , shared_name = shared_name , name = name , container = container ) # Tensor._handle_data contains information for the shape-inference code to # know the shape and dtype of the variable pointed to by a handle. Since # shape inference doesn't run in eager mode we copy this data here for # when the handle is captured by an eager mode function. # pylint: disable=protected-access full_handle_data = _combine_handle_data ( h , extra_handle_data ) _set_handle_shapes_and_types ( handle , full_handle_data , graph_mode ) # pylint: enable=protected-access # Clean up op->graph->op reference cycles. ops . dismantle_graph ( graph ) return handle