code: def monitoring(line, cell=None):
    
    parser = datalab.utils.commands.CommandParser(prog='monitoring', description=(
        'Execute various Monitoring-related operations. Use "%monitoring '
        '<command> -h" for help on a specific command.'))
  
    list_parser = parser.subcommand(
        'list', 'List the metrics or resource types in a monitored project.')
  
    list_metric_parser = list_parser.subcommand(
        'metrics',
        'List the metrics that are available through the Monitoring API.')
    list_metric_parser.add_argument(
        '-t', '--type',
        help='The type of metric(s) to list; can include wildchars.')
    list_metric_parser.add_argument(
        '-p', '--project', help='The project on which to execute the request.')
    list_metric_parser.set_defaults(func=_list_metric_descriptors)
  
    list_resource_parser = list_parser.subcommand(
        'resource_types',
        ('List the monitored resource types that are available through the '
         'Monitoring API.'))
    list_resource_parser.add_argument(
        '-p', '--project', help='The project on which to execute the request.')
    list_resource_parser.add_argument(
        '-t', '--type',
        help='The resource type(s) to list; can include wildchars.')
    list_resource_parser.set_defaults(func=_list_resource_descriptors)
  
    list_group_parser = list_parser.subcommand(
        'groups',
        ('List the Stackdriver groups in this project.'))
    list_group_parser.add_argument(
        '-p', '--project', help='The project on which to execute the request.')
    list_group_parser.add_argument(
        '-n', '--name',
        help='The name of the group(s) to list; can include wildchars.')
    list_group_parser.set_defaults(func=_list_groups)
  
    return datalab.utils.commands.handle_magic_line(line, cell, parser)
docs: Implements the monitoring cell magic for ipython notebooks.
  
    Args:
      line: the contents of the storage line.
    Returns:
      The results of executing the cell.