code: def downgrade():
      bind = op.get_bind()
      session = orm.Session(bind=bind)
  
      try:
          records = session.query(IntermediateValueModel).all()
          mapping = []
          for r in records:
              if (
                  r.intermediate_value_type
                  == IntermediateValueModel.TrialIntermediateValueType.FINITE
                  or r.intermediate_value_type
                  == IntermediateValueModel.TrialIntermediateValueType.NAN
              ):
                  continue
  
              _intermediate_value = r.intermediate_value
              if (
                  r.intermediate_value_type
                  == IntermediateValueModel.TrialIntermediateValueType.INF_POS
              ):
                  _intermediate_value = RDB_MAX_FLOAT
              else:
                  _intermediate_value = RDB_MIN_FLOAT
  
              mapping.append(
                  {
                      "trial_intermediate_value_id": r.trial_intermediate_value_id,
                      "intermediate_value": _intermediate_value,
                  }
              )
          session.bulk_update_mappings(IntermediateValueModel, mapping)
          session.commit()
      except SQLAlchemyError as e:
          session.rollback()
          raise e
      finally:
          session.close()
  
      with op.batch_alter_table(
          "trial_intermediate_values", schema=None
      ) as batch_op:
          batch_op.drop_column("intermediate_value_type")
  
      sa.Enum(IntermediateValueModel.FloatTypeEnum).drop(
          bind, checkfirst=True
      )
  
file_path: optuna/optuna/storages/_rdb/alembic/versions/v3.0.0.c.py
imports: import enum
  import numpy
  from alembic import op
  import sqlalchemy
  from sqlalchemy.exc import SQLAlchemyError
  from sqlalchemy import orm
  from typing import Optional
  from typing import Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: downgrade() without return types