parameters: (d,
                                            dtype=None,
                                            name=None,
                                            as_ref=False)
return_statement: return constant(d.value, dtype=dtype, name=name)
docstring: Function to convert Dimension to Tensor.
docstring_summary: Function to convert Dimension to Tensor.
docstring_tokens: Function to convert Dimension to Tensor .
function: def _dimension_tensor_conversion_function(d,
                                            dtype=None,
                                            name=None,
                                            as_ref=False):
    """Function to convert Dimension to Tensor."""
    _ = as_ref
    if d.value is None:
      raise ValueError(f"Cannot convert unknown Dimension {d} to a Tensor.")
    if dtype is not None:
      if dtype not in (dtypes.int32, dtypes.int64):
        raise TypeError(f"Cannot convert Dimension {d} to dtype {dtype}. "
                        "Allowed dtypes are tf.int32 and tf.int64.")
    else:
      dtype = dtypes.int32
    if name is None:
      name = "shape_as_tensor"
    return constant(d.value, dtype=dtype, name=name)
function_tokens: def _dimension_tensor_conversion_function ( d , dtype = None , name = None , as_ref = False ) : _ = as_ref if d . value is None : raise ValueError ( f"Cannot convert unknown Dimension {d} to a Tensor." ) if dtype is not None : if dtype not in ( dtypes . int32 , dtypes . int64 ) : raise TypeError ( f"Cannot convert Dimension {d} to dtype {dtype}. " "Allowed dtypes are tf.int32 and tf.int64." ) else : dtype = dtypes . int32 if name is None : name = "shape_as_tensor" return constant ( d . value , dtype = dtype , name = name )