<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def random_choice(self, actions=None, random_state=None):
 """ Return a pure action chosen randomly from `actions`. Parameters actions : array_like(int), optional(default=None) An array of integers representing pure actions. random_state : int or np.random.RandomState, optional Random seed (integer) or np.random.RandomState instance to set the initial state of the random number generator for reproducibility. If None, a randomly initialized RandomState is used. Returns ------- scalar(int) If `actions` is given, returns an integer representing a pure action chosen randomly from `actions`; if not, an action is chosen randomly from the player's all actions. """

        random_state = check_random_state(random_state)

        if actions is not None:
            n = len(actions)
        else:
            n = self.num_actions

        if n == 1:
            idx = 0
        else:
            idx = random_state.randint(n)

        if actions is not None:
            return actions[idx]
        else:
            return idx