$n$ is a given positive integer, such that it’s possible to weigh out the mass of any product weighing $1,2,3,\cdots ,ng$ with a counter balance without sliding poise and $k$ counterweights, which weigh $x_ig(i=1,2,\cdots ,k),$ respectively, where $x_i\in \mathbb{N}^*$ for any $i \in \{ 1,2,\cdots ,k\}$ and $x_1\leq x_2\leq\cdots \leq x_k.$

$(1)$Let $f(n)$ be the least possible number of $k$. Find $f(n)$ in terms of $n.$
$(2)$Find all possible number of $n,$ such that sequence $x_1,x_2,\cdots ,x_{f(n)}$ is uniquely determined.
1. **Understanding the Problem:**
   We need to find the minimum number of counterweights \( k \) such that any integer mass from \( 1 \) to \( n \) grams can be weighed using these counterweights on a balance scale. The counterweights can be placed on either side of the balance, and their weights are positive integers \( x_i \) where \( x_1 \leq x_2 \leq \cdots \leq x_k \).

2. **Formulating the Problem:**
   Since the counterweights can be placed on both sides of the balance, the mass of the object can be weighed if it is of the form:
   \[
   \sum_{i=1}^k a_i x_i, \quad a_i \in \{-1, 0, 1\}
   \]
   This means we can form any integer from \( -n \) to \( n \) using the counterweights.

3. **Counting the Number of Possible Weights:**
   The number of distinct sums we can form with \( k \) counterweights is:
   \[
   \left|\left\{\sum_{i=1}^k a_i x_i \mid a_i \in \{-1, 0, 1\}\right\}\right| = 3^k
   \]
   This includes the zero weight, so the number of non-zero weights is \( 3^k - 1 \).

4. **Relating to the Problem:**
   We need to cover the range \( \{0, \pm 1, \pm 2, \ldots, \pm n\} \), which has \( 2n + 1 \) elements. Therefore:
   \[
   2n + 1 \leq 3^k
   \]
   Solving for \( n \):
   \[
   n \leq \frac{3^k - 1}{2}
   \]

5. **Finding the Minimum \( k \):**
   Let \( m \) be the smallest integer such that:
   \[
   \frac{3^{m-1} - 1}{2} < n \leq \frac{3^m - 1}{2}
   \]
   Then \( k \geq m \). When \( k = m \), we can choose the weights as \( x_1 = 1, x_2 = 3, \ldots, x_m = 3^{m-1} \).

6. **Base 3 Representation:**
   Any integer \( p \) in the range \( 0 \leq p \leq 3^m - 1 \) can be represented in base 3 as:
   \[
   p = \sum_{i=1}^m b_i 3^{i-1}, \quad b_i \in \{0, 1, 2\}
   \]
   Shifting this range to center around zero:
   \[
   p - \frac{3^m - 1}{2} = \sum_{i=1}^m (b_i - 1) 3^{i-1}
   \]
   Letting \( a_i = b_i - 1 \), we have \( a_i \in \{-1, 0, 1\} \). Thus, any integer \( l \) in the range \( -\frac{3^m - 1}{2} \leq l \leq \frac{3^m - 1}{2} \) can be represented as:
   \[
   l = \sum_{i=1}^m a_i 3^{i-1}
   \]

7. **Conclusion for \( f(n) \):**
   The minimum number of counterweights \( k \) is:
   \[
   f(n) = m \quad \text{where} \quad m \in \mathbb{N} \quad \text{satisfying} \quad \frac{3^{m-1} - 1}{2} < n \leq \frac{3^m - 1}{2}
   \]

8. **Uniqueness of Sequence \( x_1, x_2, \ldots, x_{f(n)} \):**
   The sequence \( x_1, x_2, \ldots, x_{f(n)} \) is uniquely determined if \( n \) is of the form:
   \[
   n = \frac{3^m - 1}{2} \quad \text{for some} \quad m \in \mathbb{N}
   \]
   In this case, the weights are \( 1, 3, 9, \ldots, 3^{m-1} \).

The final answer is \( \boxed{ f(n) = m } \) where \( m \in \mathbb{N} \) satisfying \( \frac{3^{m-1} - 1}{2} < n \leq \frac{3^m - 1}{2} \).