code: def select_action(policy, observation):
      observation = torch.from_numpy(observation).float()
      probs, observation_value = policy(observation)
      # create a categorical distribution over the list of probabilities of actions
      m = Categorical(probs)
  
      # and sample an action using the distribution
      action = m.sample()
  
      # save to action buffer
      policy.saved_actions.append(
          SavedAction(m.log_prob(action), observation_value)
      )
  
      # the action to take (left or right)
      return action.item()
  
file_path: ignite/examples/reinforcement_learning/actor_critic.py
imports: import argparse
  from collections import deque, namedtuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  from torch.distributions import Categorical
  from ignite.engine import Engine, Events
label_desc: Use image node_id 1 for calling a global function with example usage: select_action(policy, observation) and returns: action