code: def test_mean_std_observation_filter_connector(self):
      for bounds in [
          (-1, 1),  # normalized
          (-2, 2),  # scaled
          (0, 2),  # shifted
          (0, 4),  # scaled and shifted
      ]:
          print(
              "Testing uniform sampling with bounds: {}".format(bounds)
          )
  
          observation_space = Box(bounds[0], bounds[1], (3, 64, 64))
          ctx = ConnectorContext(observation_space=observation_space)
          filter_connector = MeanStdObservationFilterAgentConnector(ctx)
  
          # Warm up Mean-Std filter
          for i in range(1000):
              obs = observation_space.sample()
              sample_batch = {
                  SampleBatch.NEXT_OBS: obs,
              }
              ac = AgentConnectorDataType(0, 0, sample_batch)
              filter_connector.transform(ac)
  
          # Create another connector to set state to
          _, state = filter_connector.to_state()
          another_filter_connector = (
              MeanStdObservationFilterAgentConnector.from_state(
                  ctx, state
              )
          )
  
          another_filter_connector.in_eval()
  
          # Collect transformed observations
          transformed_observations = []
          for i in range(1000):
              obs = observation_space.sample()
              sample_batch = {
                  SampleBatch.NEXT_OBS: obs,
              }
              ac = AgentConnectorDataType(0, 0, sample_batch)
              connector_output = another_filter_connector.transform(ac)
              transformed_observations.append(
                  connector_output.data[SampleBatch.NEXT_OBS]
              )
  
          # Check if transformed observations are actually mean-std filtered
          self.assertTrue(
              np.isclose(np.mean(transformed_observations), 0, atol=0.1)
          )
          self.assertTrue(
              np.isclose(np.var(transformed_observations), 1, atol=0.1)
          )
  
          # Check if filter parameters where frozen because we are not training
          self.assertTrue(
              filter_connector.filter.running_stats.num_pushes
              == another_filter_connector.filter.running_stats.num_pushes,
          )
          self.assertTrue(
              np.all(
                  filter_connector.filter.running_stats.mean_array
                  == another_filter_connector.filter.running_stats.mean_array,
              )
          )
          self.assertTrue(
              np.all(
                  filter_connector.filter.running_stats.std_array
                  == another_filter_connector.filter.running_stats.std_array,
              )
          )
          self.assertTrue(
              filter_connector.filter.buffer.num_pushes
              == another_filter_connector.filter.buffer.num_pushes,
          )
          self.assertTrue(
              np.all(
                  filter_connector.filter.buffer.mean_array
                  == another_filter_connector.filter.buffer.mean_array,
              )
          )
          self.assertTrue(
              np.all(
                  filter_connector.filter.buffer.std_array
                  == another_filter_connector.filter.buffer.std_array,
              )
          )
  
imports: import gymnasium
  from gymnasium.spaces import Box
  import numpy
  import tree
  import unittest
  from ray.rllib.algorithms.ppo.ppo import PPOConfig
  from ray.rllib.connectors.agent.clip_reward import ClipRewardAgentConnector
  from ray.rllib.connectors.agent.lambdas import FlattenDataAgentConnector
  from ray.rllib.connectors.agent.obs_preproc import ObsPreprocessorConnector
  from ray.rllib.connectors.agent.pipeline import AgentConnectorPipeline
  from ray.rllib.connectors.agent.state_buffer import StateBufferConnector
  from ray.rllib.connectors.agent.view_requirement import ViewRequirementAgentConnector
  from ray.rllib.connectors.connector import ConnectorContext
  from ray.rllib.connectors.registry import get_connector
  from ray.rllib.policy.view_requirement import ViewRequirement
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.test_utils import check
  from ray.rllib.utils.typing import ActionConnectorDataType, AgentConnectorDataType, AgentConnectorsOutput
  from ray.rllib.connectors.agent.mean_std_filter import MeanStdObservationFilterAgentConnector
label_desc: Use image node_id 6 for calling the TestAgentConnector obj's underlying member method code with example usage: obj.test_mean_std_observation_filter_connector() without return types