code: def encode_observation(ob_space, placeholder):
      '''
      Encode input in the way that is appropriate to the observation space
  
      Parameters:
      ----------
  
      ob_space: gym.Space             observation space
  
      placeholder: tf.placeholder     observation input placeholder
      '''
      if isinstance(ob_space, Discrete):
          return tf.to_float(tf.one_hot(placeholder, ob_space.n))
      elif isinstance(ob_space, Box):
          return tf.to_float(placeholder)
      elif isinstance(ob_space, MultiDiscrete):
          placeholder = tf.cast(placeholder, tf.int32)
          one_hots = [tf.to_float(tf.one_hot(placeholder[..., i], ob_space.nvec[i])) for i in range(placeholder.shape[-1])]
          return tf.concat(one_hots, axis=-1)
      else:
          raise NotImplementedErrof encode_observation(ob_space, placeholder):
      '''
      Encode input in the way that is appropriate to the observation space
  
      Parameters:
      ----------
  
      ob_space: gym.Space             observation space
  
      placeholder: tf.placeholder     observation input placeholder
      '''
      if isinstance(ob_space, Discrete):
          return tf.to_float(tf.one_hot(placeholder, ob_space.n))
      elif isinstance(ob_space, Box):
          return tf.to_float(placeholder)
      elif isinstance(ob_space, MultiDiscrete):
          placeholder = tf.cast(placeholder, tf.int32)
          one_hots = [tf.to_float(tf.one_hot(placeholder[..., i], ob_space.nvec[i])) for i in range(placeholder.shape[-1])]
          return tf.concat(one_hots, axis=-1)
      else:
          raise NotImplementedError
docs: Encode input in the way that is appropriate to the observation space
  
      Parameters:
      ----------
  
      ob_space: gym.Space             observation space
  
      placeholder: tf.placeholder     observation input placeholder