code: def pan(seg, pan_amount):
      """
      pan_amount should be between -1.0 (100% left) and +1.0 (100% right)
  
      When pan_amount == 0.0 the left/right balance is not changed.
  
      Panning does not alter the *perceived* loundness, but since loudness
      is decreasing on one side, the other side needs to get louder to
      compensate. When panned hard left, the left channel will be 3dB louder.
      """
      if not -1.0 <= pan_amount <= 1.0:
          raise ValueError(
              "pan_amount should be between -1.0 (100% left) and +1.0 (100% right)"
          )
  
      max_boost_db = ratio_to_db(2.0)
      boost_db = abs(pan_amount) * max_boost_db
  
      boost_factor = db_to_float(boost_db)
      reduce_factor = db_to_float(max_boost_db) - boost_factor
  
      reduce_db = ratio_to_db(reduce_factor)
  
      # Cut boost in half (max boost== 3dB) - in reality 2 speakers
      #   do not sum to a full 6 dB.
      boost_db = boost_db / 2.0
  
      if pan_amount < 0:
          return seg.apply_gain_stereo(boost_db, reduce_db)
      else:
          return seg.apply_gain_stereo(reduce_db, boost_db)
  
file_path: pydub/pydub/effects.py
imports: import sys
  import math
  import array
  from .utils import db_to_float, ratio_to_db, register_pydub_effect, make_chunks, audioop, get_min_max_value
  from .silence import split_on_silence
  from .exceptions import TooManyMissingFrames, InvalidDuration
label_desc: Use image node_id 9 for calling a global function with example usage: pan(seg, pan_amount) and returns: seg, seg