# Path: android_env/components/utils.py
# def touch_position_to_pixel_position(
#     touch_position: np.ndarray,
#     width_height: Sequence[int],
# ) -> Tuple[int, int]:
# def transpose_pixels(frame: np.ndarray) -> np.ndarray:
# def orient_pixels(
#     frame: np.ndarray,
#     orientation: adb_pb2.AdbCall.Rotate.Orientation) -> np.ndarray:
# 
# Path: android_env/wrappers/base_wrapper.py
# class BaseWrapper(dm_env.Environment):
#   def __init__(self, env):
#   def reset(self) -> dm_env.TimeStep:
#   def step(self, action: Any) -> dm_env.TimeStep:
#   def _reset_state(self):
#   def _process_action(self, action: Any) -> Any:
#   def _process_timestep(self, timestep: dm_env.TimeStep) -> dm_env.TimeStep:
#   def observation_spec(self) -> Dict[str, specs.Array]:
#   def action_spec(self) -> Dict[str, specs.Array]:
#   def _wrapper_logs(self) -> Dict[str, Any]:
#   def android_logs(self) -> Dict[str, Any]:
#   def raw_env(self):
#   def __getattr__(self, attr):
#   def close(self):


from typing import Dict
from android_env.components import utils
from android_env.wrappers import base_wrapper
from dm_env import specs
import dm_env
import numpy as np
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Converts pixel observation to from int to float32 between 0.0 and 1.0."""




class FloatPixelsWrapper(base_wrapper.BaseWrapper):
  """Wraps AndroidEnv for Panultimate agent."""

  def __init__(self, env: dm_env.Environment):
    super().__init__(env)
    self._should_convert_int_to_float = np.issubdtype(
        self._env.observation_spec()['pixels'].dtype, np.integer)

  def _process_observation(
      self, observation: Dict[str, np.ndarray]
  ) -> Dict[str, np.ndarray]:
    if self._should_convert_int_to_float:

# Path: android_env/components/utils.py
# def touch_position_to_pixel_position(
#     touch_position: np.ndarray,
#     width_height: Sequence[int],
# ) -> Tuple[int, int]:
# def transpose_pixels(frame: np.ndarray) -> np.ndarray:
# def orient_pixels(
#     frame: np.ndarray,
#     orientation: adb_pb2.AdbCall.Rotate.Orientation) -> np.ndarray:
# 
# Path: android_env/wrappers/base_wrapper.py
# class BaseWrapper(dm_env.Environment):
#   def __init__(self, env):
#   def reset(self) -> dm_env.TimeStep:
#   def step(self, action: Any) -> dm_env.TimeStep:
#   def _reset_state(self):
#   def _process_action(self, action: Any) -> Any:
#   def _process_timestep(self, timestep: dm_env.TimeStep) -> dm_env.TimeStep:
#   def observation_spec(self) -> Dict[str, specs.Array]:
#   def action_spec(self) -> Dict[str, specs.Array]:
#   def _wrapper_logs(self) -> Dict[str, Any]:
#   def android_logs(self) -> Dict[str, Any]:
#   def raw_env(self):
#   def __getattr__(self, attr):
#   def close(self):


# Path: android_env/wrappers/float_pixels_wrapper.py
from typing import Dict
from android_env.components import utils
from android_env.wrappers import base_wrapper
from dm_env import specs
import dm_env
import numpy as np

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Converts pixel observation to from int to float32 between 0.0 and 1.0."""




class FloatPixelsWrapper(base_wrapper.BaseWrapper):
  """Wraps AndroidEnv for Panultimate agent."""

  def __init__(self, env: dm_env.Environment):
    super().__init__(env)
    self._should_convert_int_to_float = np.issubdtype(
        self._env.observation_spec()['pixels'].dtype, np.integer)

  def _process_observation(
      self, observation: Dict[str, np.ndarray]
  ) -> Dict[str, np.ndarray]:
    if self._should_convert_int_to_float:

      float_pixels = utils.convert_int_to_float(