23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct
Dataset Card for LLMcoder-GitHub-Python-Mix-Direct Python target autocomplete suggestions in the format of conversations for OpenAI's fine-tuning. Dataset Details Dataset Description Curated by: [More Information Needed] Funded by [optional]: [More Information Needed] Shared by [optional]: [More Information Needed] Language(s) (NLP): [More Information Needed] License: [More Information Needed] Dataset Sources [optional] The data… See the full description on the dataset page: https://huggingface.co/datasets/23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct.
0216
1r_symbol2from tensorflow.python.util.tf_export import tf_export3 4 5def _convert_to_sparse_tensor(sp_input):6 """Convert `sp_input` to `SparseTensor` and return it.7 8 Args:9 sp_input: `SparseTensor` or `SparseTensorValue`.10 11 Returns:12 `sp_input` converted to `SparseTensor`.13 14 Raises:15 ValueError: if `sp_input` is neither `SparseTensor` nor `SparseTensorValue`.16 """17 if isinstance(sp_input, sparse_tensor.SparseTensorValue):18 return sparse_tensor.SparseTensor.from_value(sp_input)19 if not isinstance(sp_input, sparse_tensor.SparseTensor):20 raise TypeError("Input must be a SparseTensor.")21 return sp_input22 23 24def _convert_to_sparse_tensors(sp_inputs):25 """Convert `sp_inputs` to `SparseTensor` objects and return them.26 27 Args:28 sp_inputs: `list` or `tuple` of `SparseTensor` or `SparseTensorValue`29 objects.30 31 Returns:32 `sp_inputs` converted to `SparseTensor` objects.33 34 Raises:35 ValueError: if any item in `sp_inputs` is neither `SparseTensor` nor36 `SparseTensorValue`.37 """38 if isinstance(sp_inputs, list):39 return [_convert_to_sparse_tensor(sp_input) for sp_input in sp_inputs]40 if isinstance(sp_inputs, tuple):41 return (_convert_to_sparse_tensor(sp_input) for sp_input in sp_inputs)42 raise TypeError("Inputs must be a list or tuple.")43 44 45def _make_int64_tensor(value, name):46 if isinstance(value, compat.integral_types):47 return ops.convert_to_tensor(value, name=name, dtype=dtypes.int64)48 if not isinstance(value, tensor_lib.Tensor):49 raise TypeError("{} must be an integer value".format(name))50 if value.dtype == dtypes.int64:51 return value52 return math_ops.cast(value, dtypes.int64)53 54 55@tf_export("sparse.from_dense")56def from_dense(tensor, name=None):57 """Converts a dense tensor into a sparse tensor.58 59 Only elements not equal to zero will be present in the result. The resulting60 `SparseTensor` has the same dtype and shape as the input.61 62 >>> sp = tf.sparse.from_dense([0, 0, 3, 0, 1])63 >>> sp.shape.as_list()64 [5]65 >>> sp.values.numpy()66 array([3, 1], dtype=int32)67 >>> sp.indices.numpy()68 array([[2],69 [4]])70 71 Args:72 tensor: A dense `Tensor` to be converted to a `SparseTensor`.73 name: Optional name for the op.74 75 Returns:76 The `SparseTensor`.77 """78 with ops.name_scope(name, "dense_to_sparse"):79 tensor = ops.convert_to_tensor(tensor)80 indices = array_ops.where_v2(81 math_ops.not_equal(tensor, array_ops.zeros_like(tensor)))82 values = array_ops.gather_nd(tensor, indices)83 shape = array_ops.shape(tensor, out_type=dtypes.int64)84 return sparse_tensor.SparseTensor(indices, values, shape)85 86 87@tf_export("sparse.expand_dims")88def sparse_expand_dims(sp_input, axis=None, name=None):89 """Returns a tensor with an length 1 axis inserted at index `axis`.90 91 Given a tensor `input`, this operation inserts a dimension of length 1 at the92 dimension index `axis` of `input`'s shape. The dimension index follows python93 indexing rules: It's zero-based, a negative index it is counted backward94 from the end.95 96 This operation is useful to:97 98 * Add an outer "batch" dimension to a single element.99 * Align axes for broadcasting.100 * To add an inner vector length axis to a tensor of scalars.101 102 For example:103 104 If you have a sparse tensor with shape `[height, width, depth]`:105 106 >>> sp = tf.sparse.SparseTensor(indices=[[3,4,1]], values=[7,],107 ... dense_shape=[10,10,3])108 109 You can add an outer `batch` axis by passing `axis=0`:110 111 >>> tf.sparse.expand_dims(sp, axis=0).shape.as_list()112 [1, 10, 10, 3]113 114 The new axis location matches Python `list.insert(axis, 1)`:115 116 >>> tf.sparse.expand_dims(sp, axis=1).shape.as_list()117 [10, 1, 10, 3]118 119 Following standard python indexing rules, a negative `axis` counts from the120 end so `axis=-1` adds an inner most dimension:121 122 >>> tf.sparse.expand_dims(sp, axis=-1).shape.as_list()123 [10, 10, 3, 1]124 125 Note: Unlike `tf.expand_dims` this function includes a default value for the126 `axis`: `-1`. So if `axis is not specified, an inner dimension is added.127 128 >>> sp.shape.as_list()129 [10, 10, 3]130 >>> tf.sparse.expand_dims(sp).shape.as_list()131 [10, 10, 3, 1]132 133 This operation requires that `axis` is a valid index for `input.shape`,134 following python indexing rules:135 136 ```137 -1-tf.rank(input) <= axis <= tf.rank(input)138 ```139 140 This operation is related to:141 142 * `tf.expand_dims`, which provides this functionality for dense tensors.143 * `tf.squeeze`, which removes dimensions of size 1, from dense tensors.144 * `tf.sparse.reshape`, which provides more flexible reshaping capability.145 146 Args:147 sp_input: A `SparseTensor`.148 axis: 0-D (scalar). Specifies the dimension index at which to expand the149 shape of `input`. Must be in the range `[-rank(sp_input) - 1,150 rank(sp_input)]`. Defaults to `-1`.151 name: The name of the output `SparseTensor`.152 153 Returns:154 A `SparseTensor` with the same data as `sp_input`, but its shape has an155 additional dimension of size 1 added.156 """157 rank = sp_input.dense_shape.get_shape()[0]158 if rank is None:159 rank = array_ops.shape(sp_input.dense_shape)[0]160 axis = -1 if axis is None else axis161 162 with ops.name_scope(name, default_name="expand_dims", values=[sp_input]):163 if isinstance(axis, compat.integral_types):164 axis = ops.convert_to_tensor(axis, name="axis", dtype=dtypes.int32)165 elif not isinstance(axis, tensor_lib.Tensor):166 raise TypeError("axis must be an integer value in range [-rank(sp_input)"167 " - 1, rank(sp_input)]")168 169 # Convert axis to a positive value if it is negative.170 axis = array_ops.where_v2(axis >= 0, axis, axis + rank + 1)171 172 # Create the new column of indices for the sparse tensor by slicing173 # the indices and inserting a new column of indices for the new dimension.174 column_size = array_ops.shape(sp_input.indices)[0]175 new_index = array_ops.zeros([column_size, 1], dtype