code: def _get_time_limit(env, max_episode_length):
      """Return the time limit of a gym.Env.
  
      Args:
          env (gym.Env): the input gym.Env
          max_episode_length (int): the max episode length passed to GymEnv.
  
      Returns:
          int: if there max_episode_length is found in the gym.Env. Or None if
              not found.
  
      Raises:
          RuntimeError: if the gym.Env is wrapped by a gym.TimeLimit,
              and env.spec._max_episode_steps and env._max_episode_steps don't
              match. Or if the max_episode_length passed to GymEnv does not
              match the environment time limit.
      """
      spec_steps = None
      if (
          hasattr(env, "spec")
          and env.spec
          and hasattr(env.spec, "max_episode_steps")
      ):
          spec_steps = env.spec.max_episode_steps
      elif hasattr(env, "_max_episode_steps"):
          spec_steps = getattr(env, "_max_episode_steps")
  
      if spec_steps:
          if (
              max_episode_length is not None
              and max_episode_length != spec_steps
          ):
              warnings.warn(
                  "Overriding max_episode_length. Replacing gym time"
                  "limit ({}), with {}".format(
                      spec_steps, max_episode_length
                  )
              )
              return max_episode_length
          return spec_steps
      return max_episode_length
  
imports: import copy
  import warnings
  import akro
  import gym
  import numpy
  from garage import Environment, EnvSpec, EnvStep, StepType
label_desc: Use image node_id 1 for calling a global function with example usage: _get_time_limit(env, max_episode_length) and returns: max_episode_length, spec_steps, max_episode_length