docs: def _write_arg_to_bytes(builder, arg, args, name=None):
      """
      Writes the .__bytes__() code for the given argument
      :param builder: The source code builder
      :param arg: The argument to write
      :param args: All the other arguments in TLObject same __bytes__.
                   This is required to determine the flags value
      :param name: The name of the argument. Defaults to "self.argname"
                   This argument is an option because it's required when
                   writing Vectors<>
      """
      if arg.generic_definition:
          return  # Do nothing, this only specifies a later type
  
      if name is None:
          name = 'self.{}'.format(arg.name)
  
      # The argument may be a flag, only write if it's not None AND
      # if it's not a True type.
      # True types are not actually sent, but instead only used to
      # determine the flags.
      if arg.is_flag:
          if arg.type == 'true':
              return  # Exit, since True type is never written
          elif arg.is_vector:
              # Vector flags are special since they consist of 3 values,
              # so we need an extra join here. Note that empty vector flags
              # should NOT be sent either!
              builder.write("b'' if {0} is None or {0} is False "
                            "else b''.join((", name)
          else:
              builder.write("b'' if {0} is None or {0} is False "
                            "else (", name)
  
      if arg.is_vector:
          if arg.use_vector_id:
              # vector code, unsigned 0x1cb5c415 as little endian
              builder.write(r"b'\x15\xc4\xb5\x1c',")
  
          builder.write("struct.pack('<i', len({})),", name)
  
          # Cannot unpack the values for the outer tuple through *[(
          # since that's a Python >3.5 feature, so add another join.
          builder.write("b''.join(")
  
          # Temporary disable .is_vector, not to enter this if again
          # Also disable .is_flag since it's not needed per element
          old_flag = arg.is_flag
          arg.is_vector = arg.is_flag = False
          _write_arg_to_bytes(builder, arg, args, name='x')
          arg.is_vector = True
          arg.is_flag = old_flag
  
          builder.write(' for x in {})', name)
  
      elif arg.flag_indicator:
          # Calculate the flags with those items which are not None
          if not any(f.is_flag for f in args):
              # There's a flag indicator, but no flag arguments so it's 0
              builder.write(r"b'\0\0\0\0'")
          else:
              builder.write("struct.pack('<I', ")
              builder.write(
                  ' | '.join('(0 if {0} is None or {0} is False else {1})'
                             .format('self.{}'.format(flag.name),
                                     1 << flag.flag_index)
                             for flag in args if flag.is_flag)
              )
              builder.write(')')
  
      elif 'int' == arg.type:
          # struct.pack is around 4 times faster than int.to_bytes
          builder.write("struct.pack('<i', {})", name)
  
      elif 'long' == arg.type:
          builder.write("struct.pack('<q', {})", name)
  
      elif 'int128' == arg.type:
          builder.write("{}.to_bytes(16, 'little', signed=True)", name)
  
      elif 'int256' == arg.type:
          builder.write("{}.to_bytes(32, 'little', signed=True)", name)
  
      elif 'double' == arg.type:
          builder.write("struct.pack('<d', {})", name)
  
      elif 'string' == arg.type:
          builder.write('self.serialize_bytes({})', name)
  
      elif 'Bool' == arg.type:
          # 0x997275b5 if boolean else 0xbc799737
          builder.write(r"b'\xb5ur\x99' if {} else b'7\x97y\xbc'", name)
  
      elif 'true' == arg.type:
          pass  # These are actually NOT written! Only used for flags
  
      elif 'bytes' == arg.type:
          builder.write('self.serialize_bytes({})', name)
  
      elif 'date' == arg.type:  # Custom format
          builder.write('self.serialize_datetime({})', name)
  
      else:
          # Else it may be a custom type
          builder.write('bytes({})', name)
  
          # If the type is not boxed (i.e. starts with lowercase) we should
          # not serialize the constructor ID (so remove its first 4 bytes).
          boxed = arg.type[arg.type.find('.') + 1].isupper()
          if not boxed:
              builder.write('[4:]')
  
      if arg.is_flag:
          builder.write(')')
          if arg.is_vector:
              builder.write(')')  # We were using a tuple
  
      return True